title: FileStream returns Length = 0
body: <p>I'm trying to read a local file and upload it on ftp server. when i read a image file, everything is ok, but when i read a doc or docx file, FileStream returns length = 0. Here is my code:
  i checked with some other files, it appears that it only works fine with images and it returns 0 for any other file</p>
  
  <pre><code>if (!ftpClient.FileExists(fileName))
  {
      try
      {
          ftpClient.ValidateCertificate += (control, e) =&gt; { e.Accept = true; };
  
          const int BUFFER_SIZE = 64 * 1024; // 64KB buffer
          byte[] buffer = new byte[BUFFER_SIZE];
          using (Stream readStream = new FileStream(tempFilePath, FileMode.Open, FileAccess.Read))
          using (Stream writeStream = ftpClient.OpenWrite(fileName))
          {
              while (readStream.Position &lt; readStream.Length)
              {
                  buffer.Initialize();
                  int bytesRead = readStream.Read(buffer, 0, BUFFER_SIZE);
                  writeStream.Write(buffer, 0, bytesRead);
              }
              readStream.Flush();
              readStream.Close();
              writeStream.Flush();
              writeStream.Close();
              DeleteTempFile(tempFilePath);
              return true;
          }
      }
      catch (Exception ex)
      {
          return false;
      }
  }
  </code></pre>
  
  <p>I couldn't find whats wrong with it. could you please help me?</p>