title: How should I try 3 times if my code failed to connect a web service in C#?
body: <p>Here is my code:</p>
  
  <pre><code>FtpWebRequest reqFTP;
  reqFTP = (FtpWebRequest)FtpWebRequest.Create(Constant.IP);
  reqFTP.Credentials = new NetworkCredential(UserName, Password);
  reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
  response = (FtpWebResponse)reqFTP.GetResponse();
  Stream responseStream = response.GetResponseStream();
  reader = new StreamReader(responseStream);
  </code></pre>
  
  <p>I would like to try to connect to the web service if my code fails to connect. Only after 3 times, I would like to give up.</p>
  
  <p>How should I try?</p>
  
  <p>I am thinking about <code>try catch</code> and count the failure time but I think there will be better solutions.</p>