.net – File.Move not working properly for UNC paths

netunc

I'm attempting to use File.Move to move a file from one UNC location to another. This blows up if the UNC path for the destination happens to be the local machine (error: Access to the path is denied). Example File.Move(@"\\someServer\path\file.txt", @"\\blah2\somewhere\file.txt"). This assumes there's a network share out there somewhere named \\someServer and my local machine name is blah2. Change \\blah2 to C:\ and all is good.

Best Answer

Maybe it's a typo, but shouldn't it be @"\\blah2\somewhere\file.txt", i.e. with two backslashes?

Related Topic