Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Get the Size of a File in FTP with C#

Learn how to get the size of a file in FTP via C#.


advertisement

Using the System.Net.WebRequestMethods.FTP class, we can use the "SIZE" FTP Protocol method to get the size of the file in FTP. Below is an example in C#:

var request = (FtpWebRequest)FtpWebRequest.Create(ftpUrl);
request.Credentials = new NetworkCredential("username", "password");
request.KeepAlive = false;
//Use the GetFileSize FILE SIZE Protocol method
request.Method = WebRequestMethods.Ftp.GetFileSize;
request.UseBinary = true;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
fileSize = response.ContentLength;
response.Close();
request.Abort(); 

 

Visit the DevX Tip Bank

 





   
Srinath M. S. says: "I would love to leave a footprint in this flat world."
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date