VC++怎么获取FTP上的文件大小信息

来源:百度知道 编辑:UC知道 时间:2024/05/02 16:20:07
void CTestDlg::OnConnect()
{

strip="192.168.0.2";
strport="21";
strusr="mdy";
strpwd="mdy";
pInternetSession = new CInternetSession("MR",
INTERNET_OPEN_TYPE_PRECONFIG);
try{
pFtpConnection = pInternetSession->GetFtpConnection(strip,
strusr,strpwd,atoi(strport));

}
catch(CInternetException* pEx)
{

CString sErr;
CString FtpPath;
TCHAR szErr[1024];
pEx->GetErrorMessage(szErr, 1024);
sErr.Format( "连接FTP失败:%s", szErr );
AfxMessageBox(sErr);
pEx->Delete();

}
CString FtpPath;
m_ftpfilelst.ResetContent();
CFtpFileFind ftpfind(pFtpConnection);
BOOL bfind=ftpfind.FindFile(FtpPath);

while(bfind)
{

bfind=ftpfind.FindNextFile();
CString strpath=ftpfind.GetFileURL();

if(ftpfind.IsDirectory() )<

可以用原始指令
size [path]filename
如果文件存在 返回文件长度
否则返回5xx 失败

通过CFtpFileFind 得到文件的URL之后,然后通过CHttpFile::QueryInfo 得到文件大小。