tags:

views:

24

answers:

2

Hi,

I am trying to create a zip file and save it using DotNetZip library.

But for some reason i get a "Access to the path is denied" error when i try to save it. Code4 is below

Dim zipFile As New ZipFile()
zipFile.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression
zipFile.AddFile(filePath)
Dim tempFilePath As String = "abc.zip"
zipFile.TempFileFolder = "D:\Company Data\Operations\media\test_folder_cover_scan\"
zipFile.Save(tempFilePath) <== error line

I have given all possible access to the folder. I am using .net 3.5. This whole code works in a web service

Please advise

+1  A: 

The backslashes in your TempFileFolder are not escaped which might cause a problem. Try using a verbatim string literal instead.

zipFile.TempFileFolder = @"D:\Company Data\Operations\media\test_folder_cover_scan\"

Also, the tempFilePath in your example doesn't include a full path, could it be that it is trying to save the ZIP into a different folder from the one you are expecting (and have assigned permissions to)?

Have you assigned permissions to both the temporary file folder AND the real destination folder?

Daniel Renshaw
thanks as you pointed out the zip file was saving in some other folder. Thanks again
Amit
A: 

It looks like you don't have access to where you are trying to save it to. Try opening the command prompt and typing

takeown /f D:\Company Data\Operations\media\test_folder_cover_scan

That should give you ownership to the folder you are trying to save the file to.

Greg Treleaven