-3

I want to extract a text file located on a remote computer to my computer using c# programming language. How can I do it?

I tried using file.copy method, but was unable to do it. Can anyone suggest some other method.

Thanks in advance

user3106657
  • 95
  • 4
  • 11
  • 1
    Too vague. Is the file on a shared folder? An FTP site? What? What does "unable to do it" mean? And FYI, no-one cares how urgent this is to you. – Blorgbeard Dec 16 '13 at 09:03
  • it is a remote pc not an ftp site and when i tried file.copy it doesnt work over a network(i.e the remote pc e.g [file.copy(@"\\computer_name\\path,@"\\local_computer_name\\path")]) it shows "Path format not supported" so is there any other method to copy files over a network thanks for the reply though – user3106657 Dec 16 '13 at 09:07
  • Stackoverflow is not a code writing service - googling `c# download file` would have given you an answer. – DGibbs Dec 16 '13 at 09:09
  • An FTP site can be hosted on a remote PC, as can many many other methods of sharing files. Anyway, do you happen to have a `:` in your remote path? If so, read this: http://stackoverflow.com/questions/9323798/the-given-paths-format-is-not-supported-error-with-file-copy-method – Blorgbeard Dec 16 '13 at 09:15

1 Answers1

2

If you're using C# with file.copy you have to have the remote drive mapped to your computer and you have to be authenticated. I'm betting the problem you are having is simply related to the fact that you don't have permission to get the file you are trying to get.

If you have a valid username/pw for the remote machine, map the drive:

http://windows.microsoft.com/en-us/windows/create-shortcut-map-network-drive#1TC=windows-7

If you still have issues it's likely something on the remote machine stopping you.

Edit: If you are attempting to access a drive on the same network attempt to visit the URI in windows explorer. If you can get to it than there is another issue entirely. If you cannot get to it or if it asks for user or PW you simply don't have permission to be there.

Edit 2: Pro-tip: Avoid trying to look like you are attempting to "hack" something. I guarantee you you will be flamed and down-voted to oblivion as obvious by the other responses you've gotten.

EDIT 3: Another stack overflow article talking about the same thing with c#

Accessing a Shared File (UNC) From a Remote, Non-Trusted Domain With Credentials

Community
  • 1
  • 1
gNerb
  • 867
  • 2
  • 12
  • 28
  • But for this the folder needs to be a shared folder is there any method to copy files from an unshared folder I have the username and password of the PC -thanks – user3106657 Dec 16 '13 at 09:41
  • Are you getting any sort of error? Can you physically browse to the file on the mapped drive and copy it over manually? – gNerb Dec 16 '13 at 09:48
  • Got the answer for unshared folders too (by just making small changes in the path of the folders) thanks for your time – user3106657 Dec 16 '13 at 09:55