CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2013
    Kentucky, USA

    Question Making folders on FTP server

    .NET 2.0 on VS2010.

    Hello all!

    I'm new to the forum, and I really hope you can help me out.

    Ok, I'm writing an app that creates a specific folder tree on my FTP server. The app asks for a customer name and a project ID. When that is given and button is clicked, I want to create a folder name based off of the customer name, a subfolder under that with the Project ID number, and then 3 specific subfolders under the ProjectID folder.

    Here's my code:

    FtpWebRequest req = (FtpWebRequest)WebRequest.Create(custPath);                  //---------------------
    req.Credentials = new NetworkCredential("username", "passw");                            // Create ftp folder for 
    req.Method = WebRequestMethods.Ftp.MakeDirectory;                                       // customer name and project ID
    FtpWebResponse makeDirectoryResponse = (FtpWebResponse)req.GetResponse();   //------------------------------
    FtpWebRequest req1 = (FtpWebRequest)WebRequest.Create(custPath1);               //--------------------
    req1.Credentials = new NetworkCredential("username", "passw");                          // Creates XML folder
    req1.Method = WebRequestMethods.Ftp.MakeDirectory;                                      //
    FtpWebResponse makeDirectoryResponse1 = (FtpWebResponse)req1.GetResponse(); //--------------------
    FtpWebRequest req2 = (FtpWebRequest)WebRequest.Create(custPath2);                //-----------------------
    req2.Credentials = new NetworkCredential("username", "passw");                            // Creates the Logs folder
    req2.Method = WebRequestMethods.Ftp.MakeDirectory;                                       //
    FtpWebResponse makeDirectoryResponse2 = (FtpWebResponse)req2.GetResponse(); //-----------------------
    FtpWebRequest req3 = (FtpWebRequest)WebRequest.Create(custPath3);                //-----------------------
    req3.Credentials = new NetworkCredential("username", "passw");                            // Creates the Help Folder
    req3.Method = WebRequestMethods.Ftp.MakeDirectory;                                        //
    FtpWebResponse makeDirectoryResponse3 = (FtpWebResponse)req3.GetResponse();  //-----------------------
    It worked once, and then never worked again. That's what really boggles me. Anyways, I now get a WebException was unhandled error: Remote server returned an error (550) File unavailable (not found, no access) on line 4 or the first FtpWebResponse makeDirectoryResponse statement.

    As soon as the folders are created, I have a file uploaded to one of the folders. That actually works, but only if the folders are already there, so the above issue is holding me up.

    Any thoughts?


  2. #2
    Join Date
    Feb 2013
    Kentucky, USA

    Re: Making folders on FTP server

    nevermind. I got.
    Seems you can't make two folders (a folder and a subfolder)at the same time.


Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.