Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Commented Issue: sftpClient.WriteAllText corrupts uploaded data [1481]

$
0
0
Reproduce:

```
var sftpClient = new SftpClient( server, port, user,
new PrivateKeyFile( new MemoryStream( Encoding.ASCII.GetBytes( privateKey ) ) ) );

// 4* 1024 - data will be corrupted, 1*1024 - data will be transferred OK

var dataToUpload = new string( '0', 4 * 1024 ) + "Z";

sftpClient.Connect();
sftpClient.WriteAllText( "incoming/text.txt", dataToUpload, Encoding.ASCII );
```
Comments: ** Comment from web user: olegkap **

Hi,

Thanks for reporting it.
After analyzing it I am surprised nobody else reported it before.
It was actually a big miscalculation on my part.
May be not many people using this feature anyway since originally I created it to see if I can do it.
But anyway, I made a fix so please check out latest commit and let me know if it works.

Here is a test I used to check if it work, in case you interesting:
```
using (var sftp = new SftpClient(connectionInfo))
{
var dataToUpload = new string('0', 4 * 1024) + "Z";
sftp.Connect();

sftp.WriteAllText("text.txt", dataToUpload, Encoding.ASCII);
var downloadedDatat = sftp.ReadAllText("text.txt", Encoding.ASCII);

var file = sftp.OpenRead("text.txt");
file.Position = 1024;
using (var reader = new StreamReader(file))
{
var t1 = reader.ReadToEnd();
}

sftp.Disconnect();
}
```

Please let me know if it fixes your problem.

Thanks,
Oleg


Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>