#include "stdafx.h" #include <windows.h> #include <wininet.h> #include <iostream> #pragma comment(lib, "Wininet") using namespace std; void FileSubmit() { HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); if (hInternet == NULL) { cout << "Error: " << GetLastError(); } else { hFtpSession = InternetConnect(hInternet, L"ftp ip address", INTERNET_DEFAULT_FTP_PORT, L"username", L"passwrod", INTERNET_SERVICE_FTP, 0, 0); if (hFtpSession == NULL) { cout << "Error: " << GetLastError(); } else { if (!FtpPutFile(hFtpSession, L"e://file.txt", L"/file.txt", FTP_TRANSFER_TYPE_BINARY, 0)) { cout << L"Error: " << GetLastError(); } } } } int _tmain(int argc, _TCHAR* argv[]) { FileSubmit(); return 0; }
时间: 2024-10-13 22:26:38