本文介绍了如何改进有关在D中查找所有单词文件(* .doc)的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
地狱,我正在写一个应用程序.部分内容是将D盘中的所有word文件(* .doc)复制到MFC的E盘中.但是我发现代码并不令人满意.
code
Hell,I''m writing an application.part of it is about copy all word files(*.doc) in D disk to E disk in MFC.But I find the code is not satisfying.
code
void CMOVEDlg::CopyFile(CString destdir)//destinaton directoty is E
{
CFileFind tempFind;
CString tempFileFind;
tempFileFind.Format("%s\\*.doc",destdir);
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)://when no word file(*.doc) in the based directoty in D, bWorking is wrong and can't come into the while loop.But I want to find and copy all doc file in D.What should I do?
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
CString foundFileName;
foundFileName=tempFind.GetFileName();
if(tempFind.IsDirectory())
{
CString tempDir;
tempDir.Format("%s\\%s",destdir,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();
}
有人可以帮助我改善代码吗?在此先谢谢您.
Could someone help me improve the code? Thanks in advance.
推荐答案
这篇关于如何改进有关在D中查找所有单词文件(* .doc)的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!