-1

What I am trying to do is copying a file from a remote PC folder which is not shared. I wrote a code to connect to the PC using ManagementScope i executed some WMI queries in order to ensure that i am connected. Now the problem is when i execute the File.Copy() function as

File.Copy(@"\\Source_server\\C:\Users\ku\Desktop\test1.txt", @"\\Destination_server\\C:\Users\mo\Downloads\"); 

it shows me

Path format not supported

Does File.Copy doesn't support file copy on network?? Is there any other method to do that??

(I have the user name and password of the remote PC) -Thanks for the reply in advance

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
user3106657
  • 95
  • 4
  • 11
  • Why do you have C:\ in your path? – RononDex Dec 16 '13 at 09:31
  • Are you sure about the name of the share ? "C:" isn't a valid name. Also, the double backslash should only be at the beginning of the path. – Thomas Levesque Dec 16 '13 at 09:31
  • The answer on Extracting a file from remote server also has an answer but it needs to be a shared folder there.. But by just making few changes in the path as suggested by Casperah it works for unshared folder too.. – user3106657 Dec 16 '13 at 09:53

1 Answers1

0

You should probably use this path:

\\Source_server\C$\Users\ku\Desktop\test1.txt

But that would require administrator rights on your server.

A better solution would be to create a shared folder on the server and use that for reading and writting files.

Casperah
  • 4,504
  • 1
  • 19
  • 13