Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File.Move not working properly for UNC paths

Tags:

.net

unc

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.

like image 722
Addi Avatar asked Oct 12 '08 07:10

Addi


1 Answers

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

like image 104
Juanma Avatar answered Sep 22 '22 01:09

Juanma