Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

Can someone please help me in finding the answer to this question

Is FileInfo.MoveTo has implicit lock on file?

What actually happen when we use File.move or FileInfo.MoveTo or similar operations.

Thanks in advance

R.Manjunathan
Posted
Updated 3-Mar-11 3:54am
v2

I do not know for certain if these operations lock a file or not.

I do however see a lot of posts complaining that they do. Almost always these claims are wrong and it is another file operation that is locking the file and an exception gets called when the code reaches the Move() method.

Therefore, it might help if you explain whether this is just curiosity on your part or as a result of something that you are trying to do, that has failed.

If the latter, posting a small snippet of code that demonstrates the problem would help us to assist you.
 
Share this answer
 
If you really want to know what happens, try this.

1) Download Process Monitor[^] from Microsoft

2) Create a filter so it's only capturing events from the program in question

NB: You can create include\exclude filters over 'Actions', so you don't see too much info,

3) Make sure you're capturing events & run the program in question. Watch what happens when the code hits 'Move'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900