title: What is the right way to clean up resources after an FTP operation?
body: <p>Once I upload a file using FTP, what should I do? I generally simply close the two streams, that is: </p>
  
  <pre><code>sourceStream.Close();
  requestStream.Close();
  </code></pre>
  
  <p>What will be the effect be if they remain open? Will other users be able to login using the same credentials? Will I be able to login again? </p>
  
  <p>Here is the full code for better understanding: </p>
  
  <pre><code>FtpWebRequest request = (FtpWebRequest)WebRequest.Create(
                            "bbbbb" + "bbbbbb" + "bbb/" + hj + "/" + hjj + ".txt");
  request.Credentials = new NetworkCredential("bbbbb", "bbbbbb");
  request.Method = WebRequestMethods.Ftp.UploadFile;
  request.UsePassive = true;
  
  StreamReader sourceStream = new StreamReader(j + @"oo.txt");
  byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
  sourceStream.Close();
  request.ContentLength = fileContents.Length;
  
  Stream requestStream = request.GetRequestStream();
  requestStream.Write(fileContents, 0, fileContents.Length);
  
  sourceStream.Close();
  requestStream.Close();
  </code></pre>
  
  <p>Also, I have sometimes only the <code>request.open</code> method - which doesn't have any <code>close()</code> method assigned, and then I use <code>request.Abort()</code> at the very end of the FTP operation. Does that make any sense? </p>