// winFtpPutFiles.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;
#include<windows.h>
#include<wininet.h>
#pragma comment(lib, "Wininet")
void FileSubmit()
{
 HINTERNET hInternet;
 HINTERNET hFtpSession;
 hInternet = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
 if (hInternet == NULL)
 {
  cout << "Error: " << GetLastError();
 }
 else
 {
  hFtpSession = InternetConnectA(hInternet, "10.3.19.173", INTERNET_DEFAULT_FTP_PORT, "pc-soft7", "123", INTERNET_SERVICE_FTP, 0, 0);
  if (hFtpSession == NULL)
  {
   cout << "Error: " << GetLastError();
  }
  else
  {
   if (!FtpGetFileA(hFtpSession, "D://file-upload.txt", "/file-test.txt", FTP_TRANSFER_TYPE_BINARY, 0))//FtpPutFileA
   {
    cout << "Error: " << GetLastError();
   }
  }
 }
}

int _tmain(int argc, _TCHAR* argv[])
{
 FileSubmit();
 return 0;
}

 

posted on 2015-12-17 14:30  叶城宇  阅读(204)  评论(0编辑  收藏  举报