We have an application that exports very large data files to a windows network share. We have a potential requirement to move that file to a different folder under the same share later in the processing. We normally use File.Move to rename files in the same dir so there is little overhead. But I worry that doing this to a new dir as it will cause the data to be copied, which is not acceptable. In linux/unix the mv command is just manipulating folder nodes, so it is fast as long as it is the same device/volume. But for windows, I think in many cases it will do a copy-then-delete-source. That’s something I want to avoid.
So my question is for .NET 4 File.Move() on a windows network share where I want to move a file from one dir to another adjacent dir, will there be a cost of moving the data or will it be a fast and simple file structure operation regardless of file size?
The underlying Windows API call will just move the file’s directory entry (not copy it) if it’s moving to another folder on the same volume. This applies to network volumes just as well as local volumes. If the share doesn’t span multiple volumes somehow then you should be fine. Try it and see.