tags:

views:

89

answers:

2

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?

+1  A: 

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
That's the problem. It doesnt allow me to do that, yet I have admin access level.
Wildhorn
Domain admin access level?
Steven Sudit
Ok, finally it seems that they forgot to add me in the admin group >_<It works all good now
Wildhorn
+1  A: 

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
Is this needed to access a UNC share like `\\computername\C$`?
Steven Sudit
@Steven: Yes, see my edit.
Brian R. Bondy