C# file.copy from network path fails could not find file
this is so simple its driving me crazy. i h开发者_C百科ave another C# project where i had issues, so i then wrote a small windows form with a button that just copies a file.
File.Copy(@"\\host2\c$\test.txt", @"c:\test.txt");
i even tried
File.Copy(@"\\host2\c$\test.txt", @"\\localhost\test.txt");
each time it fails with exception could not find file "\\host2\c$\test.txt"
both hosts are win2008 in the same windows domain, i am domain admin with local admin rights on both hosts. i can do it from command line fine, and i can start/run to host name in windows find and copy also.
i am at a loss here? i googled around and lots of people had issues when one host was in domain in one in a workgroup, but that is not the case with my issue.
any help or ideas?
Can you manually get to that link through Windows Explorer? Any chance the default Windows share (C$) is disabled?
No reason in the world why that code won't work.
I know you've said you can do it in a command line, but I suspect the problem is still something to do with either permissions or shares. Try starting your app as administrator, see if that helps
Try disabling UAC remote restrictions on remote host http://support.microsoft.com/kb/951016/
精彩评论