我有這個簡單的代碼上傳檔案到伺服器,但它似乎不工作,不上傳任何檔案(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.
2011-03-26
Kobe
+0
什麼是錯誤檢查讓你(即檢查傳回并調用GetLastError())? –
2011-03-26 22:08:41
+0
它傳回ERROR_SUCCES –
2011-03-26 22:14:34
+0
對不起,我犯了一個錯誤,是的,它傳回一個錯誤(32):程序無法通路該檔案,因為它正在被另一個程序使用。 –
2011-03-26 22:15:54