이 간단한 코드를 사용하여 서버에 파일을 업로드 할 수 있지만 작동하지 않으며 파일을 업로드하지 않습니다 (FtpPutFile이 0을 반환 함). 나는 FileZilla의 서버를 사용하고이 내 코드와 FileZilla의이 말씀 : C++을 사용하여 ftp 서버에 파일을 업로드 할 수 없습니다.
void upload()
{
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
hFtpSession = InternetConnect(hInternet,"127.0.0.1",INTERNET_DEFAULT_FTP_PORT,"vbx","pass",INTERNET_SERVICE_FTP, 0,0);
FtpPutFile(hFtpSession, "c:\\stories.txt", "e:\\text.txt", FTP_TRANSFER_TYPE_BINARY, 0);
InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);
}
(000011)3/27/2011 0:01:53 AM - (not logged in) (127.0.0.1)> USER vbx
(000011)3/27/2011 0:01:53 AM - (not logged in) (127.0.0.1)> 331 Password required for vbx
(000011)3/27/2011 0:01:53 AM - (not logged in) (127.0.0.1)> PASS *******
(000011)3/27/2011 0:01:53 AM - vbx (127.0.0.1)> 230 Logged on
(000011)3/27/2011 0:01:53 AM - vbx (127.0.0.1)> disconnected.
감사합니다.
편집 : GetLastError와 GetLastError() returns: The process cannot access the file because it is being used by another process.
오류 확인을 사용하면 (즉, 수표가 반환되고 GetLastError()가 호출됩니다.) –
그것은 ERROR_SUCCES를 반환합니다 – Kobe
죄송합니다. 예, 오류 (32)를 반환합니다 : 다른 프로세스에서 사용 중이기 때문에 프로세스가 파일에 액세스 할 수 없습니다. – Kobe