Results 1 to 3 of 3

Thread: [RESOLVED] FTP Error Cannot send a content-body with this verb-type

  1. #1

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Resolved [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

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: FTP Error Cannot send a content-body with this verb-type

    Hope this helps
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width