Tuesday, August 18, 2009

Asp.net Code can not download Zip file of more then 12 mb

Asp.net Code can not download Zip file of more then 12 mb

hi ,

There is file server and Webserver.On file server there are several files.Now when I try to

download a Zip file from file server,Zip file is truncated mid-download (usually around 12mb) and therefore unreadable but when I try to download any other file which is not Zip file and which is of same size or even bigger size, then it downloads that file ,I mean to say it is unable to download only Zip file of more than 12 mb.

What could be the possible reason for this.application has been developed using C# ,ASP.net..

code which is downloading is -

private void DownloadFile(string MyFilePath)
{
const int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];

FileStream stream = new FileStream(
MyFilePath,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
try
{

string contentDisposition = string.Format(
"attachment; filename=\"{0}\"",
Path.GetFileName(MyFilePath));
Response.AddHeader(
"Content-Disposition",
contentDisposition);

for (; ; )
{
int bytesRead = stream.Read(buffer, 0, bufferSize);
if (0 == bytesRead)
{
// all done
break;
}
Response.OutputStream.Write(buffer, 0, bytesRead);
}
}
finally
{
stream.Close();
}
}





View Full Details...............................

No comments:

Post a Comment