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".
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?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();
Help appreciated.
http://social.msdn.microsoft.com/for...6-ff8c326f0d41





Reply With Quote