title: MoveFile() doesn't work
body: <p>I'm trying to move some files from a directory into another directory on the same drive. All destination directories exist but <code>MoveFile()</code> doesn't work and <code>GetLastError()</code> returns 0.
  I'm new to C++ and i have no idea what is causing this problem.
  here's the code:</p>
  
  <pre><code>try
  {
    destinationFilePath = i-&gt;FilePath;
    destinationFilePath=destinationFilePath.substr(destinationFilePath.find(GENERAL_SAVE_PATH) + strlen(GENERAL_SAVE_PATH.c_str()));
    destinationFilePath = Backup_Save_Path + destinationFilePath;
  
    vector&lt;string&gt; folders;
    StringSplit(destinationFilePath,"\\",folders);
    string pathToCreate;
    string backSlash = "\\";
    for(vector&lt;string&gt;::const_iterator j = folders.begin(); j != folders.end(); ++j)
    {
        pathToCreate += j-&gt;c_str() + backSlash;
        if (pathToCreate.find(".txt") == std::string::npos)
           CreateBackupFolders(pathToCreate);
    }
  
    if (MoveFile(lastExportedFilePath.c_str(),destinationFilePath.c_str()))
       AfxMessageBox("moved");
    else
    {
       DWORD dw = GetLastError();
       AfxMessageBox("Couldn't move");
    }
  
    lastExportedFilePath = i-&gt;FilePath;
  }
  catch(...)
  {
    Log(LOG_PATH_LOG_INSERTING, LOG_TYPE_EXCEPTION, "ExportLogsToDB()", "Move", destinationFilePath, "");
  }
  </code></pre>