Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows - C#- Directory.Move

Tags:

c#

io

windows

Is it guaranteed that Directory.Move only renames and not copy/delete as long as it is on the same logical drive?

like image 742
user441660 Avatar asked Sep 05 '25 03:09

user441660


2 Answers

In fact Directory.Move fails if you attempt to move a directory to a different volume. If you want to perform such a move you have to do the Copy/Delete yourself. I think you can safely assume that Directory.Move will only ever succeed if the operation can be performed without copying files.

like image 147
David Heffernan Avatar answered Sep 07 '25 15:09

David Heffernan


Directory.Move is an atomic operation if that's what you're getting at. It doesn't do it as 2 operations. On NTFS at least.

like image 21
George Duckett Avatar answered Sep 07 '25 15:09

George Duckett