First of all, I understand that I am using ASP.NET 4.5 with DefaultAppPool (integrated 4.0). I also configured anonymous access to the DefaultAppPool user. I have granted all access to DefaultAppPool. System.Security.Principal.WindowsIdentity.GetCurrent()gives me the same user. But when the next line works, it gives me an exception Access to the path 'XXXX' is denied.. Then, for testing purposes, I gave all the rights to the user EveryOne, but still get the same error. Here is a line of code. Pay attention to trus
using (ZipArchive archive = new ZipArchive(zipStream))
{
foreach (ZipArchiveEntry file in archive.Entries)
{
file.ExtractToFile(location,true);
}
}
Here is the stacktrace,
[UnauthorizedAccessException: Access to the path 'XXX' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +10793558
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1352
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +65
System.IO.Compression.ZipFileExtensions.ExtractToFile(ZipArchiveEntry source, String destinationFileName, Boolean overwrite) +96
XX.XX.XX.ExtractZipFile(Stream zipStream, String location) in XX.cs:44
XX.XX.XX.XX.XX.XX.ExtractZipFile(Stream zipStream, String location) in XXX.cs:17

source
share