我有一个图像文件。我使用 ftp 将其上传到我的服务器。这是最有效的方法吗?
System.Net.FtpWebRequest ftpClient = (System.Net.FtpWebRequest)System.Net.WebRequest.Create( _serverPath + "/" + _filename);
ftpClient.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
ftpClient.Credentials = new System.Net.NetworkCredential("ftp://website.ftp", "thepassword");
ftpClient.UseBinary = true;
ftpClient.KeepAlive = true;
System.IO.Stream rs = ftpClient.GetRequestStream();
rs.Write(fileContents, 0, fileContents.Length);
rs.Close();
FtpWebResponse uploadResponse = (FtpWebResponse)ftpClient.GetResponse();
value = uploadResponse.StatusDescription;
uploadResponse.Close();
谢谢任何人?