I have a problem when opening a zip file. I am using this code to zip the file:
public static string Zip_File(string soruce , string target)
{
try
{
byte[] bufferWrite;
using (FileStream fsSource = new FileStream(soruce, FileMode.Open, FileAccess.Read, FileShare.Read))
{
bufferWrite = new byte[fsSource.Length];
fsSource.Read(bufferWrite, 0, bufferWrite.Length);
using (FileStream fsDest = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write))
{
using (GZipStream gzCompressed = new GZipStream(fsDest, CompressionMode.Compress, true))
{
gzCompressed.Write(bufferWrite, 0, bufferWrite.Length);
bufferWrite = null;
fsSource.Close();
gzCompressed.Close();
fsDest.Close();
}
}
}
return "success";
}
catch (Exception ex)
{
return ex.Message;
}
}
When I call this function am receiving "success" message, but I can't able to open the zip file.
ZipFiles.Zip_File(@"C:\Documents and Settings\ccspl\Desktop\IntegrityDVR.mdb", @"C:\Documents and Settings\ccspl\Desktop\a.zip")
This is my function call code:
the compressed(folder) is invalid or corrupted ...> this is error message which I have received