我想获取FTP服务器上特定的文件名,可是程序进行到
find=m_pFtpFind->FindFile(fstring);
就死了!不知道是什么原因,请各位高手指教!谢谢!
char filename[25];
char fstring[25];
/*ftp使用的变量*/
CFtpConnection *m_connection;      
CInternetSession *m_session=new CInternetSession;
try
{
m_connection=m_session->GetFtpConnection(rm_ip,rm_usr,rm_psw);
}
catch(CInternetException* pEx)
{
pEx->Delete();
m_connection=NULL;
AfxMessageBox("FTP服务器连接失败!\r\n");
return 1;
}
m_connection->SetCurrentDirectory(rm_dir);
CFtpFileFind* m_pFtpFind=new CFtpFileFind(m_connection);
BOOL find; memset(fstring,0,sizeof(fstring));
sprintf(fstring,"%s*.HLB*",xz[i].string);
find=m_pFtpFind->FindFile(fstring);
int nItem=0;
CString str;
while (find)
{
memset(filename,0,sizeof(filename));
find=m_pFtpFind->FindNextFile();
str=m_pFtpFind->GetFileName();/*获得一个文件名*/
if (m_pFtpFind->IsDirectory())/*判断是否是目录*/
continue;
sprintf(filename,"%s",str.GetBuffer(str.GetLength())); 
int length;
int position;
int num;
char temp[25];
memset(temp,0,sizeof(temp));
length=strlen(filename);
position=strrchr(filename,32)-filename+1;
num=length-position;
strncpy(temp,filename+position,num);
strcpy(filelocal[filel].filename,temp);
filelocal[filel].zt=0;
filel++;
} m_connection->Close();
delete m_connection;
delete m_session