Vote count:
0
I am using this code to upload file to FTP server:
String source = @"E:\\file\e1.txt";
String ftpurl = @"http://ift.tt/1ywnh1j";
String ftpusername = @"myusername@myftpserver.pl";
String ftppassword = @"mypassword";
string filename = Path.GetFileName(source);
string ftpfullpath = ftpurl + "/" + filename;
Debug.WriteLine("Uploading...");
var fs = File.OpenRead(source);
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
ftp.Timeout = -1;
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
Stream ftpstream = ftp.GetRequestStream();
fs.CopyTo(ftpstream);
ftpstream.Close();
Debug.WriteLine("Upload complete.");
File is quit big - about 50 mb. So, after uploading the file, appliaction hangs. Here is an output in debug window
Uploading... //immediately after executing the code
The thread 0xd50 has exited with code 0 (0x0). //after some time
And it never prints:
Upload complete.
Note, that after thread exits, upload is still in progress, it's not cancelled. I have noticed this problem, when I was trying to send multiple files from List in a loop - application hangs after uploading first file. Can someone help me?
asked 34 secs ago
c# - uploading file on FTP is not working properly
Aucun commentaire:
Enregistrer un commentaire