我写了个函数来判断FTP上的文件夹是否存在,如下:bool FtpModule::IsFolderExist( const char* szFolder )
{
CFtpFileFind ff(m_pFtp);
if ( !ff.FindFile( szFolder ) )
{
// 抛异常
}
if ( !ff.FindNextFile() )
{
return false;
}
if ( !ff.IsDirectory() )
{
return false;
}
return true;
}但是实际运行中,很多时候文件夹明明存在,也会在 FindNextFile() 那里返回false。
这是怎么回事呢?我这样写有问题吗?
{
CFtpFileFind ff(m_pFtp);
if ( !ff.FindFile( szFolder ) )
{
// 抛异常
}
if ( !ff.FindNextFile() )
{
return false;
}
if ( !ff.IsDirectory() )
{
return false;
}
return true;
}但是实际运行中,很多时候文件夹明明存在,也会在 FindNextFile() 那里返回false。
这是怎么回事呢?我这样写有问题吗?
LPCTSTR pstrName = NULL,
DWORD dwFlags = INTERNET_FLAG_RELOAD
);
Parameters
pstrName
A pointer to a string containing the name of the file to find. If NULL, the call will perform a wildcard search (*). dwFlags
The flags describing how to handle this session. These flags can be combined with the bitwise OR operator (|) and are as follows: INTERNET_FLAG_RELOAD Get the data from the wire even if it is locally cached. This is the default flag. INTERNET_FLAG_DONT_CACHE Do not cache the data, either locally or in any gateways. INTERNET_FLAG_RAW_DATA Override the default to return the raw data (WIN32_FIND_DATA structures for FTP). INTERNET_FLAG_SECURE Secures transactions on the wire with Secure Sockets Layer or PCT. This flag is applicable to HTTP requests only. INTERNET_FLAG_EXISTING_CONNECT If possible, reuse the existing connections to the server for new FindFile requests instead of creating a new session for each request.
我现在直接忽略了它的返回值……貌似可以了~