C # file.copy from network path could not find file

It's so easy to drive me crazy. I have another C # project where I am having problems, so I wrote a small window form with a button that just copies the file.

File.Copy(@"\\host2\c$\test.txt", @"c:\test.txt"); 

I even tried

 File.Copy(@"\\host2\c$\test.txt", @"\\localhost\test.txt"); 

every time it crashes with the exception could not find file "\\host2\c$\test.txt"

both hosts are win2008 in the same Windows domain, I am a domain administrator with local administrator rights on both hosts. I can do this from the command line in order, and I can start / run the hostname in windows, find and copy as well.

Am I at a loss here? I googled around and many people had problems when one owner was in a domain in one in a workgroup, but this does not apply to my problem.

any help or ideas?

+4
source share
3 answers

Can you manually go to this link through Windows Explorer? Any chance that the Windows share (C $) is disabled?

+3
source

There is no reason in the world why this code will not work.

I know you said that you can do this on the command line, but I suspect that the problem is still related to permissions or promotions. Try to run the application as an administrator, see if this helps

+1
source

Try disabling remote UAC restrictions on the remote host http://support.microsoft.com/kb/951016/

0
source

All Articles