Documentation for thinner points FtpWebRequest

I am creating a universal FTP class for .NET. Everything seems to work fine for me, but there are a few details that I'm a little unsure about. And the documentation, such as in MSDN, gives absolutely no information about these details.

For example, when executing request methods such as WebRequestMethods.Ftp.UploadFile and WebRequestMethods.Ftp.RemoveDirectory , can I safely ignore the contents of the response? Or maybe there is some information in the answer that I need to check?

I'm sure GetResponse() throws an exception for almost all error conditions, but how can I be sure? Again, documents simply do not cover this type of information.

Can someone solve this issue or recommend the documentation I should use?

+4
source share
1 answer

Yes, you can ignore them; however, I would suggest ensuring that they are accessed in a controlled manner and within the scope of the attempts ... finally, tags to ensure that the response is closed in the finally tag:

 using (FtpWebResponse response = (FtpWebResponse)ftpWebRequest.GetResponse()) { try { using (Stream dataStream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(dataStream)) { return reader.ReadToEnd(); } } } finally { response.Close(); } } 
0
source

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


All Articles