批量修改文件夹下的子文件夹名字不行,该怎么解决
批量修改文件夹下的子文件夹名字不行
我写了个程序,希望对指定文件夹下的子文件夹名进行修改,添加一个时间在原有的名字后面,但是有点问题,麻烦各位帮我看一下,3QQ。
------解决方案--------------------
什么问题?Debug下调试一下看看
------解决方案--------------------
能把问题说一下吗
------解决方案--------------------
m_NewFileName请设置绝对路径。
不能用Rename把C盘的东西移动到你工程所在盘(假设在D盘)。
我写了个程序,希望对指定文件夹下的子文件夹名进行修改,添加一个时间在原有的名字后面,但是有点问题,麻烦各位帮我看一下,3QQ。
- C/C++ code
void CCopyFileDlg::RenameFile() { UpdateData(); CTime dntm; dntm=CTime::GetCurrentTime(); CString time = dntm.Format("%Y%m%d"); CFileFind finder; CString NewFileName,str,FileExtend,FileName,FileRoot=""; BOOL bWorking = finder.FindFile(m_SourcePath+"\\*.*"); EnablePathName(m_OldFileName); while(bWorking) { bWorking=finder.FindNextFile(); if (finder.IsDots()) continue; m_OldFileName=finder.GetFilePath(); FileName=finder.GetFileName(); m_Num++; str.Format("%d%d%d",m_Num/100,m_Num/10,m_Num%10); for (int i=0;i<FileName.GetLength();i++) { if(FileName[i]=='.')break; } FileExtend=FileName.Right(FileName.GetLength()-i); m_NewFileName = FileName+time; CFile::Rename(m_OldFileName,m_NewFileName); } UpdateData(FALSE); } void CCopyFileDlg::EnablePathName(CString &FileName) { CString str1,str2; for (int i=0;i<FileName.GetLength();i++) { if (FileName[i]=='\\') { str1=FileName.Left(i); str2=FileName.Right(FileName.GetLength()-i); str1+="\\"; FileName=str1+str2; i++; } } return; }
------解决方案--------------------
什么问题?Debug下调试一下看看
------解决方案--------------------
能把问题说一下吗
------解决方案--------------------
m_NewFileName请设置绝对路径。
不能用Rename把C盘的东西移动到你工程所在盘(假设在D盘)。