CFileFind的问题

来源:互联网 发布:php判断网址是否有效 编辑:程序博客网 时间:2024/05/21 09:26


void DeleteDirectory(CString& str){
    CString path(str);
    path
+=CString(TEXT("//*.*"));
    CFileFind finder;
    BOOL isFind
=(BOOL)finder.FindFile(path);
   
while(isFind){
        isFind
=finder.FindNextFileW();
       
if(!finder.IsDots()){
           
if(finder.IsDirectory()){
                wcout
<<finder.GetFilePath().GetBuffer(200)<<endl;
                finder.GetFilePath().ReleaseBuffer();
                DeleteDirectory(finder.GetFilePath());
            }
           
//DeleteFile(finder.GetFilePath());
            wcout<<finder.GetFilePath().GetBuffer(200)<<endl;
            finder.GetFilePath().ReleaseBuffer();   
        }
    }
    finder.Close();
}
            CFileFind ff;
            CString str;
           
if(ff.FindFile(CString(TEXT("*.*")))){
                ff.FindNextFileW();
                str
=ff.GetFilePath();
            }
            ff.Close();
            DeleteDirectory(str);



问题是:为什么如果我的输入目录含有汉字,就有问题呢?
比如,如果我获得的str为D://win32或MFC代码,最后只有输出D://win32

我是再觉得自己写的代码带太多的工程文件,不利于备份,想写一个删除不必要的工程文件的时候产写的上面的代码,可是老出错,请大牛指教

 

回复于:2009-12-13 23:23:41

可能与你问题无关,你为什么要GetBuffer?cout

 

回复于:2009-12-13 23:25:30

请google“wcout 无法输出中文”

原创粉丝点击