I want to move a directory to a new location, then I use the Directory.Move
API, but it does not work for the UNC path, e.g.
Directory.Move(@"\\Server1\Path1", @"\\Server1\Path2");
It will throw below exception
[System.IO.IOException] = {"Source and destination path must have identical roots. Move will not work across volumes."}
And I did not find any wordings tell this API not work for UNC path from MSDN. So which API works for the UNC path?
You can't MOVE if they are on different volumes. MOVE is a file system operation that changes where it lives without copying it. To move across different volumes, you would have to copy it, then delete the old one.
It has nothing to do with UNC. Moving from C:\something to D:\something would error the same way and for the same reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With