伙计们,我正在尝试重新制作文件(将 _DONE 添加到其名称中)
我的研究表明 File.move(OLDNAME,NEWNAME) 是我需要的。于是,我做到了,
try
{
string oldname = name;
//XYZ_ZXX_ZZZ
string newName = ToBeTested + "_DONE.wav";
//rename file
//NOTE : OldName is already in format XYZ_III_SSS.wav
File.Move(oldname, newName);
}
catch (Exception exRename)
{
string ex1 = exRename.ToString();
//logging an error
string m = "File renaming process failed.[" + ex1 + "]";
CreateLogFile(p, m);
}
但它不承担任何结果(文件未重命名),但记录了异常。
像这样
System.IO.FileNotFoundException: Could not find file 'C:\Users\Yachna\documents\visual studio 2010\Projects\FolderMonitoringService_RCCM\FolderMonitoringService_RCCM\bin\Debug\54447874_59862356_10292013_153921_555_877_400_101.wav'.
File name: 'C:\Users\Yachna\documents\visual studio 2010\Projects\FolderMonitoringService_RCCM\FolderMonitoringService_RCCM\bin\Debug\54447874_59862356_10292013_153921_555_877_400_101.wav'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.Move(String sourceFileName, String destFileName)
at RCCMFolderMonitor.Monitor.OnChanged(Object source, FileSystemEventArgs e) in C:\Users\Yachna\documents\visual studio 2010\Projects\FolderMonitoringService_RCCM\RCCMFolderMonitor\Monitor.cs:line 209]
我做错了什么 ?