title: Corrupted Binary Files after Transfer libcurl
body: <p>I am transferring a binary file (.exe) with FTP using libcurl, and saving it to a local file. The problem is that after the file is transferred, it is altered and is no longer a valid Win32 application, and doesn't run. Here's how I'm doing it:</p>
  
  <pre><code>CURL *curl;
  
  curl = curl_easy_init();
      FILE* f = fopen("C:\\blah.exe", "w");
  
  if(curl) {
      curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.mysite.com");
      curl_easy_setopt(curl, CURLOPT_USERPWD, "blah:blah");
      curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD);
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, &amp;f);
  } else {
              fclose(f);
      return CURL_EASY_INIT_FAIL;
  }
  
      fclose(f);
  </code></pre>
  
  <p>The file is written but is bigger than it is on the FTP server. Like I said, trying to run it results in the "%1 is not a valid Win32 application" error. Did I forget to set an option or something?</p>