Archived Forum Post

Index of archived forum posts


550 Create directory operation failed.

Jul 01 '16 at 08:37

Why do I get this error? Here is my code snippet:

    success = ftp.CreateRemoteDir("/test/update");
    DllDate: Jun 23 2016
    UnlockPrefix: anything
    Architecture: Little Endian; 32-bit
    Language: Visual C++ 11.0 (32-bit)
    VerboseLogging: 1
    dir: /test/update
            sendingCommand: MKD /test/update
            replyLineQP: 550 Create directory operation failed.
            commandResponse: 550 Create directory operation failed.
            statusCode: 550
        Simple path command failed.
        statusCode: 550
        reply: 550 Create directory operation failed.


There are several reasons why the above code failed.

  1. The remote directory already exists.
  2. An FTP account is usually restricted to it's HOME directory and below. It's generally not permissible (due to server-side permissions) to create files or directories anywhere on the remote filesystem.
  3. Given that an FTP account is restricted to the HOME directory and below, it never really makes sense to pass an absolute directory path to CreateRemoteDir (or any method that accepts are remote path). Relative directory paths should be used. (An absolute directory path begins with "/", whereas a relative path does not.)
  4. It is not a good idea to assume that the FTP server will automatically parse the directory path and either (a) create any subdirectories required or (b) create the final directory in the path. A more durable and failsafe solution that will work with any FTP server is this:
    // First try changing the remote directory to "test"
    success = true;
    if (!ftp.ChangeRemoteDir("test"))
    success = ftp.CreateRemoteDir("test");
    if (success) success = ftp.ChangeRemoteDir("test");
    if (!success)
        return false;
    // Now create the directory "update" (which will be located within the "test" 
    // subdirectory because we've changed the current remote directory to "test")
    success = ftp.CreateRemoteDir("update");
    if (!success)
    return false;