我要下载文件,FTP服务器连接都没问题,但是下不来文件这是为什么?
是不是我的URL写错呢? CString strServerName = "193.168.1.45";
CString strUserName = "administrator";
CString strPassword = "";
CString strURL = "193.168.1.45/haha.txt";
CString strLocalFile = "C:\haha.txt";
try
{
CInternetSession* objSession = new CInternetSession(strServerName,1);
CFtpConnection* objConn = objSession->GetFtpConnection(strServerName,strUserName,strPassword);
objConn->GetFile(strURL,strLocalFile,FALSE);
objConn->Close();
delete objConn;
objSession->Close();
delete objSession;
}
catch(CInternetException* pEx)
{
TCHAR szErr[1024];
if (pEx->GetErrorMessage(szErr, 1024))
AfxMessageBox(szErr, MB_OK);
else
AfxMessageBox("sdfs", MB_OK);
pEx->Delete();
}
是不是我的URL写错呢? CString strServerName = "193.168.1.45";
CString strUserName = "administrator";
CString strPassword = "";
CString strURL = "193.168.1.45/haha.txt";
CString strLocalFile = "C:\haha.txt";
try
{
CInternetSession* objSession = new CInternetSession(strServerName,1);
CFtpConnection* objConn = objSession->GetFtpConnection(strServerName,strUserName,strPassword);
objConn->GetFile(strURL,strLocalFile,FALSE);
objConn->Close();
delete objConn;
objSession->Close();
delete objSession;
}
catch(CInternetException* pEx)
{
TCHAR szErr[1024];
if (pEx->GetErrorMessage(szErr, 1024))
AfxMessageBox(szErr, MB_OK);
else
AfxMessageBox("sdfs", MB_OK);
pEx->Delete();
}
还有,这个url地址是不是这样写的?
c:\\123\\122
strURL="test.txt"对应X:\Inetpub\Ftproot\test.txt
strURL="\Doc\test.txt"对应X:\Inetpub\Ftproot\Doc\test.txt