How to know when a file transfer is completed (from server to client)

I pull the file from the ftp server, and I have problems with the convenience of my method of verifying the successful completion of the transfer.

There seems to be a more specific way to detect successful transmission. Any ideas?

My code is:

var request = (FtpWebRequest)FtpWebRequest.Create(ftpFilePath); request.KeepAlive = false; request.UseBinary = true; request.UsePassive = false; request.Credentials = new NetworkCredential("Username", "Password"); request.Method = WebRequestMethods.Ftp.DownloadFile; FtpWebResponse response = (FtpWebResponse)request.GetResponse(); using (var stream = response.GetResponseStream()) { using (var reader = new StreamReader(stream)) { contents = reader.ReadToEnd(); } } //Check to see if transfer was successful if (response.StatusDescription.StartsWith("2")) transferSuccessful = true; 
+4
source share
1 answer

Check out FtpWebResponse.StatusCode for success. e.g. FtpStatusCode.ClosingData

+5
source

Source: https://habr.com/ru/post/1413161/


All Articles