如何将流数据保存为 ftp 服务器中的图像?
FileInfo fileInf = new FileInfo("1" + ".jpg");
string uri = "ftp://" + "hostip//Data//" + fileInf.Name;
FtpWebRequest reqFTP;
// Create FtpWebRequest object from the Uri provided
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(
"ftp://" + "ipaddress//Data//" + fileInf.Name));
// Provide the WebPermission Credintials
reqFTP.Credentials = new NetworkCredential("username",
"password");
// By default KeepAlive is true, where the control connection is
// not closed after a command is executed.
reqFTP.KeepAlive = false;
// Specify the command to be executed.
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
// Specify the data transfer type.
reqFTP.UseBinary = true;
// Notify the server about the size of the uploaded file
//reqFTP.ContentLength = fileInf.Length; ???
using (var img = Image.FromStream(image))
{
img.Save(adduser.User_Id + ".jpg", ImageFormat.Jpeg);
}
你能告诉我吗?