المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to Upload large size file to server



C# Programming
06-30-2009, 04:50 PM
Hi friend i am creating WindowDesktop application that will upload a large size of file to the server.
now when i upload file of small size its uploaded with no problem but when i upload large size of 62Mb or so it throw exception. can any body tell me that how can i upload large file and can i also pause uploading and resume Uploading feature


FileStream stream = new FileStream("C:\\XYZ.zip", FileMode.Open);


byte[] buffer = new byte[stream.Length];
int i =0;
while ((i = stream.Read(buffer,0, buffer.Length))>0)
{

FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://ftp.abc.com/" + Path.GetFileName("C:\\XYZ.zip"));
try
{
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("demo123", "Demo123");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;

request.Timeout = int.MaxValue;

Stream reqStream = request.GetRequestStream();
// reqStream.Write(buffer, 0, buffer.Length);
reqStream.BeginWrite(buffer, 0, buffer.Length, callBack, "AA");
reqStream.Close();
}
catch (Exception ex)
{

}

}
stream.Close();>


i use both Write and BeginWrite method



WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP