Hello,
I am trying to upload a file to a ftp site.
I have my code pasted below.
*** at this point an error pops up
Message = "The remote server returned an error: (500) Syntax error, command unrecognized."
Could someone please let me know as to why this is happening?
Thanks very much.
Rahul
I am trying to upload a file to a ftp site.
I have my code pasted below.
Code:
FtpWebRequest reqFTP; reqFTP = (FtpWebRequest)FtpWebRequest.CreateDefault(new Uri(@"ftp://<IPAddress>/<FolderName>/" + fileInf.Name)); reqFTP.Credentials = new NetworkCredential(@"username", "password"); reqFTP.Method = WebRequestMethods.Ftp.UploadFile; reqFTP.ContentLength = fileInf.Length; int buffLength = 2048; byte[] buff = new byte[2048]; int contentLen; FileStream fs = fileInf.OpenRead(); ***Stream strm = reqFTP.GetRequestStream(); contentLen = fs.Read(buff, 0, buffLength); while (contentLen != 0) { strm.Write(buff, 0, contentLen); contentLen = fs.Read(buff, 0, buffLength); } strm.Close(); fs.Close();
Message = "The remote server returned an error: (500) Syntax error, command unrecognized."
Could someone please let me know as to why this is happening?
Thanks very much.
Rahul
Comment