1
Vote

Not able to delete file from Zip

description

I am using SLSharpZipLib in my Silverlight application.
Where I am also trying to delete 1 or 2 files from Zip without unzipping it.

I have written below code to achieve the same :
                    Stream stream = dialog.File.OpenRead();
                    ZipFile z = new ZipFile(stream);
                    z.BeginUpdate();
                    bool state= z.Delete(directoryname + "test.txt");
                    z.CommitUpdate();
                    z.Close();
Here Delete method also returns me true value. But when CommitUpdate is executed I get exception that "Stream does not support writing."
Stacktrace:
at System.IO.FileStream.WriteByte(Byte value)
at ICSharpCode.SharpZipLib.Zip.ZipFile.WriteLEShort(Int32 value)
at ICSharpCode.SharpZipLib.Zip.ZipFile.WriteLEInt(Int32 value)
at ICSharpCode.SharpZipLib.Zip.ZipFile.WriteLocalEntryHeader(ZipUpdate update)
at ICSharpCode.SharpZipLib.Zip.ZipFile.CopyEntryDirect(ZipFile workFile, ZipUpdate update, Int64& destinationPosition)
at ICSharpCode.SharpZipLib.Zip.ZipFile.RunUpdates()
at ICSharpCode.SharpZipLib.Zip.ZipFile.CommitUpdate()
at ZipSample.MainPage.CheckFileExists()



Is there anything that I am missed out?
Please help asap.

comments