File.Move does not work properly for UNC paths

I am trying to use File.Move to move a file from one UNC location to another. This explodes if the UNC path for the destination is a local machine (error: path access denied). An example File.Move(@"\\someServer\path\file.txt", @"\\blah2\somewhere\file.txt"). This assumes that there is a network resource named \\ someServer, and the name of my local machine is blah2. Change \\ blah2 to C: \ and all is well.

+3
source share
6 answers

Maybe this is a typo, but it should not be @"\\blah2\somewhere\file.txt", i.e. with two backslashes?

+4
source

Shouldn't the server name in your path start with two abbreviations?
e.g. @ "\\ someServer \ path \ file.txt"

+1

Windows , ( ACL) - . , C $, , , , , "" " ".

, , " " → " ", , . "" → " " → " " → " " .

+1

. , - ? UNC- ?

0

I had the same problem and the file was locked by another program (Windows Explorer), in my case I unlocked the file using unlocker. this happened to me when accessing a file using a UNC path. The File.Move method works with access to it through the local path.

It seems to me that I did not get this behavior when manually renaming a file via UNC / local path.

0
source

File.Move file path does not accept UNC path

http://support.microsoft.com/KB/112744

0
source

Source: https://habr.com/ru/post/1698179/


All Articles