Answered by:

The process cannot access the file because it is being used by another process.

Question

File.Move(file.a,file.b) returns an exception saying: "The process cannot access the file because it is being used by another process." I am 100% sure that no other process is using the file. About an hour ago the code worked, since then I installed a new signature maybe that's what's causing it. But I didn't find any information about that on the internet.

Answers

Sorry that we cannot do a troubleshooting for your code
snippet, as we cannot execute it.

Since the problem is a specified file is being used by
another process, well, we can check which process is using this file, to do this, consider
use the Process
Monitor , notice the “Path” column, and set the filter condition as "Path=the_file_want_to_monitor_path", but first of all, restart your computer to make sure no process is access this file.

By using Process monitor, we can check a specific file is being used by which process, and if the process is just the process that throw
the exception “cannot access file…”, I believe you need to take a closely look
at your code, and find if there is a open file statement without matched close
file statement.

Regards,

Xun

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706

Heureka! It not a signature issue. Although I said that I'm 100% sure that no other process is using the file it turns out that it is just not process I started which is using the file. Looking at the task manager I noticed that after each move operation involving a file with a known extension a process of the corresponding application (e.g. AcroRd32.exe after moving a pdf) has been started. After changing the extension to something not associated with any application it works.

Still, how do I keep the file from being found? Can I lock it somehow or tell the other applications that there is a three-headed monkey behind them to make them look away?

Sorry that we cannot do a troubleshooting for your code
snippet, as we cannot execute it.

Since the problem is a specified file is being used by
another process, well, we can check which process is using this file, to do this, consider
use the Process
Monitor , notice the “Path” column, and set the filter condition as "Path=the_file_want_to_monitor_path", but first of all, restart your computer to make sure no process is access this file.

By using Process monitor, we can check a specific file is being used by which process, and if the process is just the process that throw
the exception “cannot access file…”, I believe you need to take a closely look
at your code, and find if there is a open file statement without matched close
file statement.

Regards,

Xun

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706