0

I am trying to add a file to an existing zip file using SharpZipLib. Preferably without creating any temporary files as the zip is large (about 2GB). And when using a temp file, the NTFS rights to the zip are changed. Not a good idea.

I tried the method supplied in the answer here sharpziplib - can you add a file without it copying the entire zip first? like so:

Public Function AddManifestToZip(ByVal zipfilePath As String, ByVal manifestFilePath As String) As Boolean
    Dim zipArchive As SharpZip.ZipFile = New SharpZip.ZipFile(zipfilePath)
    If File.Exists(manifestFilePath) Then
        Dim diskarchivestorage = New DiskArchiveStorage(zipArchive, FileUpdateMode.Direct)
        zipArchive.BeginUpdate(diskarchivestorage)
        zipArchive.Add(manifestFilePath)
        zipArchive.CommitUpdate()
        zipArchive.Close()
        Return True
    End If
    Return False
End Function

However I get the following error from the .CommitUpdate(): "Stream does not support writing"

Anyone got any clues how to circumvent this?

Community
  • 1
  • 1
  • "And when using a temp file, the NTFS rights to the zip are changed. Not a good idea" The permissions should be correct for the folder and user. What's changing? – Terry Carmen Jul 26 '16 at 15:38
  • One or two users are removed from the access list. And the IIS_IUSRS had full access, but after the .commitupdate() only 'special permissions' – waveparticlepixel Jul 27 '16 at 07:58
  • The file is probably inheriting the folder permissions, which are by default limited for folders in the web tree. If you save your files to a location that has the correct permissions, it should solve your problems. – Terry Carmen Jul 27 '16 at 13:50

0 Answers0