title: c# rename file before ftping
body: <p>How can I rename the file to a timestamp or random unique number before it is actually ftped to the server?</p>
  
  <p>example: if i select C:\taco.pdf  ..... 1321981871.pdf is actually what would be ftp'd to the server.</p>
  
  <pre><code>FileInfo toUpload = new FileInfo(this.txtFile.Text);
  
   FtpWebRequest request =
              (FtpWebRequest)WebRequest.Create(
              "ftp://192.168.0.186" + "/" + toUpload.Name
              );
  
   request.Method = WebRequestMethods.Ftp.UploadFile;
  
  request.Credentials =
              new NetworkCredential("myuser","mypassword");
  
  Stream ftpStream = request.GetRequestStream();
          FileStream file = File.OpenRead(this.txtFile.Text);
  
   int length = 1024;
          byte[] buffer = new byte[length];
          int bytesRead = 0;
  
  
          do
          {
              bytesRead = file.Read(buffer, 0, length);
              ftpStream.Write(buffer, 0, bytesRead);
          }
          while (bytesRead != 0);
  
   file.Close();
          ftpStream.Close();
  </code></pre>