我想编辑 FTP 服务器上的图像。我使用 SSH.net,这是我的代码:
using (var client = new SftpClient(ftpUploadPath, ftpPort, ftpUser, ftpPassword))
{
client.Connect();
using (var stream = new MemoryStream())
{
client.DownloadFile(fileName, stream);
using (var img = Image.FromStream(stream, true))
{
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
img.Save(stream, ImageFormat.Jpeg);
client.UploadFile(stream, fileName);
}
}
}
一切都是正确的,直到“client.UploadFile”通过 0 个八位字节图像擦除 FTP 服务器上的图像。FTP 服务器上的图像是 .jpg。我已经将“client.UploadFile”与 FileStream 一起使用,它工作正常。但是在这种情况下,我不想将文件保存在我的 IIS 服务器上,对其进行修改然后将其上传到 FTP 服务器......知道吗?