File.Move error in C#
Posted
by Bi
on Stack Overflow
See other posts from Stack Overflow
or by Bi
Published on 2010-05-13T08:16:15Z
Indexed on
2010/05/13
8:24 UTC
Read the original article
Hit count: 144
c#
Hi
I am trying a simple move as shown below and get the following error: "The process cannot access the file because it is being used by another process." How do I fix this? Thanks.
FileInfo file1 = new FileInfo(srcFile);
if (file1.Exists)
{
FileInfo file2 = new FileInfo(destFile);
if (!file2.Exists)
{
try
{
File.Move(srcFile, destFile);
}
catch (System.IO.IOException e)
{
Console.WriteLine(e.Message);
}
}
}
© Stack Overflow or respective owner