I am using c#.net application in which I need to download a zip file using c# codebase.I am using the following code for downloading the file:
Response.ContentType = "application/zip"
Response.AppendHeader("Content-Disposition", string.Format("attachment; filename = {0}", System.IO.Path.GetFileName(sZipFileName)));
Response.TransmitFile(sZipFilePath);
HttpContext.Current.ApplicationInstance.CompleteRequest();
The zip file is transmitted but when I tried to open the zip file after downloading, I am getting an error saying " Cannot open the file : the file does not look to be a valid archive"
Please let me know where am I doing wrong and how to get a zip file and extract it without any errors.
Thanks in Advance
I have tested the flowing code and it works, so sharing it. One mandatory thing that I did is to use "
Response.Flush();
".