G
Guest
Hello!
I want to move file from one directory to other.
The exception is:
“The process cannot access the file because it is being used by another
process.â€
Maybe it is because I use this file in the project, and do some operations
on it,
And then try to move it to other folder?
Maybe I forget something? ("Free" the file?) or something else ?
Thank U for your help ...
Value of the program:
bckUpFilePath = @"c:\BckUpRet\"
OrgFileName="DocDraft1.txt"
Thanks again.
I want to move file from one directory to other.
The exception is:
“The process cannot access the file because it is being used by another
process.â€
Maybe it is because I use this file in the project, and do some operations
on it,
And then try to move it to other folder?
Maybe I forget something? ("Free" the file?) or something else ?
Thank U for your help ...
Value of the program:
bckUpFilePath = @"c:\BckUpRet\"
OrgFileName="DocDraft1.txt"
Code:
fi = di.GetFiles();
bckUpFilePath = sBckUpDirectory + "\\";
foreach (FileInfo fTemp in fi)
{
OrgFileName = fTemp.Name;
// Ensure that the target file does not exist.
if (File.Exists(bckUpFilePath+OrgFileName)) <--- works
File.Delete(bckUpFilePath+OrgFileName); <--- works // Move this
file to another file. fTemp.MoveTo(bckUpFilePath+OrgFileName); <--- don’t
work
}
Thanks again.