Downloading a cab file without any chenge in content or size..
-
Hi, I have a web application(ASP.net, C#) in which the user is be able to download a .cab file to the PC by clicking on a button after making a file selection. I tried many methods for accomplishing the download task. The code i tried is given below. Response.ContentType = "APPLICATION/OCTET-STREAM"; System.String disHeader = "Download; Filename=\"" + myfilename+ "\""; Response.AppendHeader("Content-Disposition", disHeader); System.IO.FileInfo fileToDownload = new System.IO.FileInfo(myfilepath); Response.Flush(); Response.WriteFile(fileToDownload.FullName); or FileStream MyFileStream = new FileStream(myfilepath, FileMode.Open); long FileSize; FileSize = MyFileStream.Length; byte[] Buffer = new byte[(int)FileSize]; MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length); MyFileStream.Close(); Response.ContentType = "application/octet-stream"; Response.AddHeader("content-disposition", "attachment; filename=" + myfilename); Response.BinaryWrite(Buffer); When i tried these two methods, i could download the files to the PC. The user has to copy the cab file to the Pocket PC device for installing it. The file downloaded through the web application may have some problem so that it cannot be installed on the Pocket PC. When i tried to install the original file from the repository, it worked fine. It means that there occurs some problem with the cab file while it is being downloaded. The original file is having the size 420 KB. But the file downloaded is having size 432 KB. Could anybody guide me to solve the problem? Thanks in advance. Nicejith
-
Hi, I have a web application(ASP.net, C#) in which the user is be able to download a .cab file to the PC by clicking on a button after making a file selection. I tried many methods for accomplishing the download task. The code i tried is given below. Response.ContentType = "APPLICATION/OCTET-STREAM"; System.String disHeader = "Download; Filename=\"" + myfilename+ "\""; Response.AppendHeader("Content-Disposition", disHeader); System.IO.FileInfo fileToDownload = new System.IO.FileInfo(myfilepath); Response.Flush(); Response.WriteFile(fileToDownload.FullName); or FileStream MyFileStream = new FileStream(myfilepath, FileMode.Open); long FileSize; FileSize = MyFileStream.Length; byte[] Buffer = new byte[(int)FileSize]; MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length); MyFileStream.Close(); Response.ContentType = "application/octet-stream"; Response.AddHeader("content-disposition", "attachment; filename=" + myfilename); Response.BinaryWrite(Buffer); When i tried these two methods, i could download the files to the PC. The user has to copy the cab file to the Pocket PC device for installing it. The file downloaded through the web application may have some problem so that it cannot be installed on the Pocket PC. When i tried to install the original file from the repository, it worked fine. It means that there occurs some problem with the cab file while it is being downloaded. The original file is having the size 420 KB. But the file downloaded is having size 432 KB. Could anybody guide me to solve the problem? Thanks in advance. Nicejith
Hi, I don't know if you've tried this, but you could try:
public void SendFile(String myFilePath) {
Response.TransmitFile(myFilePath)
}For more information on
Response.TransmitFile
then go to: http://msdn.microsoft.com/msdnmag/issues/06/09/webdownloads/default.aspx -
Hi, I don't know if you've tried this, but you could try:
public void SendFile(String myFilePath) {
Response.TransmitFile(myFilePath)
}For more information on
Response.TransmitFile
then go to: http://msdn.microsoft.com/msdnmag/issues/06/09/webdownloads/default.aspx