1

I have an image file. I upload this to my server using ftp. Is this the most efficient way to do it?

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();

thanks anyone?

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
Andrew Simpson
  • 6,883
  • 11
  • 79
  • 179

0 Answers0