我有這個簡單的代碼上傳文件到服務器,但它似乎不工作,不上傳任何文件(FtpPutFile返回0)。我正在使用FileZilla服務器,這是我的代碼和FileZilla所說的:無法上傳文件到FTP服務器使用C++
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() returns: The process cannot access the file because it is being used by another process.
什麼是錯誤檢查讓你(即檢查返回並調用GetLastError())? – 2011-03-26 22:08:41
它返回ERROR_SUCCES – Kobe 2011-03-26 22:14:34
對不起,我犯了一個錯誤,是的,它返回一個錯誤(32):進程無法訪問該文件,因爲它正在被另一個進程使用。 – Kobe 2011-03-26 22:15:54