0

I tried with WMI but doesn't work.
I also tried this with LogonUser but it doesnt work because LogonUser only works for local computers.

So how can I copy a file or at least get connected to the computer so it accept System.IO.File.Copy?

Community
  • 1
  • 1
Wildhorn
  • 926
  • 1
  • 11
  • 30
  • what is your network security setup? Are you using ActiveDirectory? Are you logged in as a domain user on the box running the code? – Grzenio Sep 03 '10 at 14:18

2 Answers2

1

If you need a share with that you can access on every computer, you can try \\computername\c$.

If your app has admin-rights, you can copy files to every location on the c:. Use \\computername\d$ for d: and so on.

Hope this helps.

HCL
  • 36,053
  • 27
  • 163
  • 213
1

You need to p/invoke WNetUseConnection to get access to the computer first, then use a UNC path to access the file and use normal file I/O. Here is some sample C# code.

You would for example access c:\test.txt on a computer named MONKEY on your LAN via a path like this: @"\\MONKEY\c$\test.txt".

Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636