When I first upload the file and upload it through SSH.NET, everything works fine.
client.DownloadFile(url, x) Using fs= System.IO.File.OpenRead(x) sFtpClient.UploadFile(fs, fn, True) End Using
However, now I have to (not download the file), but download the file stream:
Dim ba As Byte() = client.DownloadData(url) Dim stream As New MemoryStream() stream.Write(ba, 0, ba.Length) sFtpClient.UploadFile(stream, fn, True)
What happens is that the UploadFile
method considers that it succeeded, but on the FTP server itself, the file is created with a size of 0 KB.
What am I doing wrong? I also tried adding the buffer size, but it did not work.
I found the code on the Internet. Should I do something like this:
client.ChangeDirectory(pFileFolder); client.Create(pFileName); client.AppendAllText(pFileName, pContents);
source share