<p>I'm using the following code to send a file to a Unix server:</p>
<p> </p>
<p> using (Renci.SshNet.SftpClient sftpObj = new Renci.SshNet.SftpClient(destination, destination_userid, destination_pwd))</p>
<p> {</p>
<p> sftpObj.BufferSize = ((1024 * 32 - 38) / 2); //<-- I've left this out, changed #'s, etc...</p>
<p> sftpObj.ConnectionInfo.Timeout = TimeSpan.FromMinutes(2);</p>
<p> sftpObj.OperationTimeout = TimeSpan.FromMinutes(8);</p>
<p> sftpObj.Connect();</p>
<p> sftpObj.UploadFile(strminput, Path.Combine(destination_dir, destination_file));</p>
<p> //IAsyncResult asynch = sftpObj.BeginUploadFile(strminput, Path.Combine(destination_dir, destination_file), true, null, null);</p>
<p> //while (!asynch.IsCompleted)</p>
<p> // Thread.Sleep(1);</p>
<p> //sftpObj.EndUploadFile(asynch);</p>
<p> sftpObj.Disconnect();</p>
<p> sftpObj.Dispose();</p>
<p> }</p>
<p> </p>
<p>I'm picking up a file from the same server the application is running on, putting it in a stream and sending it to the Unix server.</p>
<p> </p>
<p>Most of the time it works correctly, but every once in a while (even on the same file) it will start writing out the file correctly, but then a bunch of 00's instead of the real data and pick right back up correctly. As you can see, I've tried sync and async methods. Same results.</p>
<p> </p>
<p>The files that are correct are the same exact size as the files that are not (18.5MB) when using the same source files.</p>
<p> </p>
<p>Please let me know if you need more info and thank you very much in advance for any help.</p>
Comments:
<p> </p>
<p> using (Renci.SshNet.SftpClient sftpObj = new Renci.SshNet.SftpClient(destination, destination_userid, destination_pwd))</p>
<p> {</p>
<p> sftpObj.BufferSize = ((1024 * 32 - 38) / 2); //<-- I've left this out, changed #'s, etc...</p>
<p> sftpObj.ConnectionInfo.Timeout = TimeSpan.FromMinutes(2);</p>
<p> sftpObj.OperationTimeout = TimeSpan.FromMinutes(8);</p>
<p> sftpObj.Connect();</p>
<p> sftpObj.UploadFile(strminput, Path.Combine(destination_dir, destination_file));</p>
<p> //IAsyncResult asynch = sftpObj.BeginUploadFile(strminput, Path.Combine(destination_dir, destination_file), true, null, null);</p>
<p> //while (!asynch.IsCompleted)</p>
<p> // Thread.Sleep(1);</p>
<p> //sftpObj.EndUploadFile(asynch);</p>
<p> sftpObj.Disconnect();</p>
<p> sftpObj.Dispose();</p>
<p> }</p>
<p> </p>
<p>I'm picking up a file from the same server the application is running on, putting it in a stream and sending it to the Unix server.</p>
<p> </p>
<p>Most of the time it works correctly, but every once in a while (even on the same file) it will start writing out the file correctly, but then a bunch of 00's instead of the real data and pick right back up correctly. As you can see, I've tried sync and async methods. Same results.</p>
<p> </p>
<p>The files that are correct are the same exact size as the files that are not (18.5MB) when using the same source files.</p>
<p> </p>
<p>Please let me know if you need more info and thank you very much in advance for any help.</p>
Comments:
No response from the user