I have generated a zip using streamwriter in isolated storage named temp.zip and return its bytes in stream for extraction. Please find the code as below
stream = LoadZipFromLocalFolder(filename);
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var zipStream = new ZipInputStream(stream))
{
ZipEntry entry;
//EOF in header occuring on below line
while ((entry = zipStream.GetNextEntry()) != null)
{
string directoryName = Path.GetDirectoryName(entry.Name);
string fileName = Path.GetFileName(entry.Name);
if (!string.IsNullOrEmpty(fileName))
{
if (!isoStore.DirectoryExists(directoryName))
{
isoStore.CreateDirectory(directoryName);
}
string fileFullPath = Path.Combine(directoryName, fileName);
Debug.WriteLine(fileFullPath);
using (var streamWriter = new BinaryWriter(new IsolatedStorageFileStream(fileFullPath, FileMode.Create, FileAccess.Write, FileShare.Write, isoStore)))
{
var buffer = new byte[2048];
int size;
while ((size = zipStream.Read(buffer, 0, buffer.Length)) > 0)
{
streamWriter.Write(buffer, 0, size);
}
streamWriter.Close();
streamWriter.Dispose();
}
}
}
}
}
When I created temp.zip, it has ReadWrite,Share permissions and also I tried to unzip manually, then its getting extracted properly without causing any error, but in code its showing error EOF in HEADER.
Please help..
Thanks