Hi ,
I have created a function to create zip file but when I extract the zip in windows the file which was zip does not contains the extension. please let me know how to get the extension.
calling of the function is like this:
string filepATH = Server.MapPath("Doc\\hello.docx");string fileoutpath = Server.MapPath("Doc\\hellox.zip");
CompressFile(filepATH, fileoutpath);
public bool CompressFile(string file, string outputFile) { try { //open the file to be compressed using (var inFile = File.OpenRead(file)) { //create a new stream from the resulting zip file to be created using (var outFile = File.Create(outputFile)) { //now create a GZipStream object for writing the input file to using (var compress = new GZipStream(outFile, CompressionMode.Compress, false)) { //buffer array to hold the input file in byte[] buffer = new byte[inFile.Length]; //read the file into the FileStream int read = inFile.Read(buffer, 0, buffer.Length); //now loop (as long as we have data) and //write to the GZipStream while (read > 0) { compress.Write(buffer, 0, read); read = inFile.Read(buffer, 0, buffer.Length); } } } } return true; } catch (IOException ex) { // MessageBox.Show(string.Format("Error compressing file: {0}", ex.Message)); return false; } }