[RESOLVED] FTP Error Cannot send a content-body with this verb-type
I have some code which I had working fine as below but now for some reason it throws the error "Cannot send a content-body with this verb-type".
Code:
try
{
String destinationPath = ConfigurationManager.AppSettings["HostedPath"].ToString();
String sourcePath = ConfigurationManager.AppSettings["InternalPath"].ToString();
String destinationFolder = destinationPath + "/" + vendor;
String sourceFolder = sourcePath;
String uploadFile = sourceFolder + "\\" + filename;
const String username = "";
const String password = "";
String URI = destinationFolder + "/" + filename;
System.Net.FtpWebRequest ftp = FtpWebRequest.Create(URI) as FtpWebRequest;
System.Net.FtpWebRequest ftpdrs = FtpWebRequest.Create(URI) as FtpWebRequest;
ftp.Proxy = null;
//ftp.Credentials = new System.Net.NetworkCredential(username, password);
ftp.KeepAlive = false;
ftp.UseBinary = false;
ftpdrs.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
ftpdrs.GetRequestStream();
//ftpdrs.GetResponse().GetResponseStream();
byte[] b = System.IO.File.ReadAllBytes(uploadFile);
//System.IO.Stream clsStream = ftp.GetResponse().GetResponseStream();
System.IO.Stream clsStream = ftp.GetRequestStream(); clsStream.Write(b, 0, b.Length);
clsStream.Close();
clsStream.Dispose();
Now I googled the error and found replies as below and changed the request stream lines in the above to the commented out response streams, this no longer throws the error but now no longer copies the file to the ftp site?
Help appreciated.
http://social.msdn.microsoft.com/for...6-ff8c326f0d41
Re: FTP Error Cannot send a content-body with this verb-type
Re: FTP Error Cannot send a content-body with this verb-type
Yes I just realised im only trying to write and found some half finished code which was also trying to read, I removed the un needed code and it works again now