FTP用GetFile()下载文件只能在程序根目录不能指定目录,求助
本帖最后由 oyljerry 于 2012-11-24 15:09:36 编辑
CString strname;
strname=file.GetFileName();
CString strdir;
pFtpConnection->GetCurrentDirectory(strdir);
pFtpConnection->GetFile(selfile,strname); //下载文件到选定的本地位置
pInternetSession->Close(); //关闭废弃的会话
this->ConnectFtp(); //保持持续会话
pFtpConnection->SetCurrentDirectory(strdir);
this->UpdateDir();
AfxMessageBox("下载成功!");
编译成功后连上ftp服务器只能下载文件到根目录,不能指定目录,求指导
[解决办法]
GetFile可以指定下载文件的路径啊,看msdn:
BOOL GetFile(
LPCTSTR pstrRemoteFile,
LPCTSTR pstrLocalFile,
BOOL bFailIfExists = TRUE,
DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL,
DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY,
DWORD_PTR dwContext = 1
);
Both pstrRemoteFile and pstrLocalFile can be either partially qualified filenames relative to the current directory or fully qualified. A backslash (\) or forward slash (/) can be used as the directory separator for either name. GetFile translates the directory name separators to the appropriate characters before they are used.