Trying to do error handling when connecting to an ftp server. Disappears this so far:
try { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri); request.Credentials = new NetworkCredential(login, password); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("Команда выполнена, статус {0}", response.StatusDescription); reader.Close(); response.Close(); } catch (UriFormatException) { // тут вызов метода для повторного указания uri,login и password } How can I check the availability of a successful connection to the server after entering uri and login with a password? While processing an error only if uri is such, for example: string uri = "localhost"; .