Access to the path 'c:\windows\system32\inetsrv

Nov 9, 2011 at 2:05 PM

I am using DotNetZip Library to zip files and render it on the browser. But getting permissions issue (stack trace shown below) when calling zip.Save("R.zip").

 

System.UnauthorizedAccessException was caught  Message=Access to the path 'c:\windows\system32\inetsrv\DotNetZip-amowf3ht.tmp' is denied.  Source=mscorlib  StackTrace:       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)       at 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)       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)       at System.IO.FileStream..ctor(String path, FileMode mode)       at Ionic.Zip.SharedUtilities.CreateAndOpenUniqueTempFile(String dir, Stream& fs, String& filename)       at Ionic.Zip.ZipFile.get_WriteStream()       at Ionic.Zip.ZipFile.Save()       at Ionic.Zip.ZipFile.Save(String fileName)       at Opin.WebContent.Layouts.Opin.ReportsDownload.btnDownloadContent_Click(Object sender, EventArgs args)  InnerException: 

 

 

I changed the TempFileFolder to another folder which has permissions for NETWORKSERVICE account. Still not working and same permission issues. 

 

Any thoughts?

Coordinator
Nov 10, 2011 at 8:27 PM

Show your code.

Show the code where you set the TempFileFolder and try saving the Zip file.

 

Coordinator
Nov 10, 2011 at 8:29 PM

also, what version of DotNetZip are you using?

Nov 11, 2011 at 5:33 AM

I figured it out. 

Issue:

zip.TempFileFolder = @"D\tempfolder";

zip.Save("my.zip"); 

 

Fix:

zip.TempFileFolder = @"D\tempfolder";

zip.Save(@"D\tempfolder\my.zip");


Apr 12, 2012 at 10:28 AM
Edited Apr 12, 2012 at 10:40 AM

i have folder with name  ZippedFiles in my site's root directory , iam saving all my zip files in that folder.

i have another folder with name images which consists of all my image files.the following is the code to zip the image file.iam using DotNetZipLib-DevKit-v1.9 with .net 3.5

use the namespace

using Ionic.Zip;

string zipPath = Server.MapPath("~/ZippedFiles/MyZipFile1.zip");
using (ZipFile zip = new ZipFile())
{
zip.AddFile(Server.MapPath("~/images/img1.jpg"),string.Empty);
zip.AddFile(Server.MapPath("~/images/img2.jpg"),string.Empty);
zip.AddFile(Server.MapPath("~/images/img2.jpg"),string.Empty);
zip.Save(zipPath);
}
the zipped file will created with all the images in it,if you have different file formats and you want your files to be saved in respective folders,you can specify the code as follows.
string zipPath = Server.MapPath("~/ZippedFiles/MyZipFile1.zip");
using (ZipFile zip = new ZipFile())
{
zip.AddFile(Server.MapPath("~/images/img1.jpg"), "images");
zip.AddFile(Server.MapPath("~/images/img2.jpg"), "images");
zip.AddFile(Server.MapPath("~/pdfs/customer.pdf"), "files");
zip.AddFile(Server.MapPath("~/images/sample.doc"), "files");
zip.Save(zipPath);
}
the newly created zipped file now contains two folders images ---- > img1.jpg , img2,.jpg and another folder files --> customer.pdf, sample.doc

I hope this will help someone. Thanks