title: FtpPutFile keeps not sending file
body: <p>I've written an FTP client in <code>C++</code> to send files to an FTP server automatically. However I have an error when I try to use the function <code>FtpPutFile()</code>. Everytime I use it I get <code>error 2</code> from the function <code>GetLastError()</code> and <code>no error</code> from <code>perror()</code>. I know it's not because of the firewall as I can do it manually from my command prompt. Also, it's not because I can't connect to the ftp server, as I have checked for errors in this part of the code.</p>
  
  <p>I am also developing this in a <code>Visual Studio 2010</code> environment and I have set my <code>Character Set</code> to <strong>Not Set</strong> so I can use a <code>string.c_str()</code>.  </p>
  
  <p>So the only thing that can be wrong is how I call the function itself. The next part is my code that refers to the function that is suposed to send a file through <code>FTP</code>:</p>
  
  <pre><code>void fileTransfer(const std::string&amp; filename)
  {
      LPCTSTR pstrServer = TEXT("ip.address");
      LPCTSTR pstrUserName = TEXT("user");
      LPCTSTR pstrPassword = TEXT("pass");
      LPCTSTR lpszLocalFile = (LPCTSTR)filename.c_str();
      LPCTSTR lpszNewRemoteFile = (LPCTSTR)filename.c_str();
  
      HINTERNET hSession = InternetOpen(0, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
      HINTERNET hService = InternetConnect(hSession, pstrServer,    INTERNET_DEFAULT_FTP_PORT, pstrUserName, pstrPassword, INTERNET_SERVICE_FTP, 0, 0);
  
     if(FtpPutFile(hService, filename.c_str(), filename.c_str(), FTP_TRANSFER_TYPE_ASCII, 0))
     {
          printf("File copied\n");
     }
     else
     {
          printf("File not copied\n");
          std::cerr &lt;&lt; "Error: " &lt;&lt; GetLastError() &lt;&lt; std::endl;
          perror( "Error transfering file" );
          putchar('\n');
     }
     InternetCloseHandle(hService);
     InternetCloseHandle(hSession);
  }
  </code></pre>
  
  <p>Does anyone know what might be wrong here? Because this code only runs if a certain type of file <code>.txt</code> with a certain structure name, is found. But in the <code>FtpPutFile()</code> it says it is not found. Even if I print <code>filename.c_str()</code> I get the proper file name.</p>