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
  • 62,720
  • 18
  • 132
  • 197
Andrew Simpson
  • 6,539
  • 10
  • 70
  • 168

0 Answers0