如何使用Rename()
char buffer[1024];this->UpdateData(TRUE);
try{
CFile *originalfile=new CFile(this->original,CFile::modeRead);
CFile *aimfile=new CFile(this->aim,CFile::modeCreate|CFile::modeWrite);
while(originalfile->Read(buffer,sizeof(buffer))){
aimfile->Write(buffer,sizeof(buffer));
}
aimfile->Flush();
aimfile->Close();
originalfile->Close();
CFile::Rename(this->aim,this->original);
CFile::Remove(this->original);
delete originalfile;
delete aimfile;
this->MessageBox("移动成功!","提示",MB_ICONASTERISK);
}
catch(CFileException e){
this->MessageBox("移动失败!","提示",MB_ICONERROR);
}
this->aim和this->original是文件路径名,在将this->aim改名为this->original时,总是提示“对一未命名的文件存取被拒绝”,目录我也用了双斜杠,但是还是出现这个问题!