如何将txt文件复制到远程计算机。 [英] How can i copy a txt file to a remote machine.
本文介绍了如何将txt文件复制到远程计算机。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的代码,它是将文件复制到任何远程计算机的标准代码。
但是它不断弹出这个错误:找不到网络路径。
请帮帮我!
我的尝试:
Below is my code which is standard code to copy a file to any remote computer.
But it keeps popping up this error : The network path was not found.
Please help me out !
What I have tried:
private void CopyFilesToSharedLocation1()
{
IntPtr admin_token = default(IntPtr);
WindowsIdentity wid_admin = null;
WindowsImpersonationContext wic = null;
if (LogonUser("WIN-ABC/Administrator", "WIN-ABC", "ABCDEF", 9, 0, ref admin_token) != 0)
{
wid_admin = new WindowsIdentity(admin_token);
wic = wid_admin.Impersonate();
System.IO.File.Copy("E:/Temp/abc.txt", "\\\\WIN-ABC\\TestFolder\\abc.txt", true);
}
else
{
}
}
推荐答案
您的IIS代码运行的匿名用户无权访问网络,您将会需要将您的代码运行的用户更改为有权访问该共享的域帐户。为了抢先您的下一个问题,谷歌iis更改匿名用户或iis更改用户代码运行为,因为它取决于您的网站设置方式。
The anonymous user your IIS code is running under doesn't have access to the network, you'll need to change the user your code runs under to a domain account that has access to that share. To pre-empt your next question, google "iis change anonymous user" or "iis change user code runs as", as it depends how your site is set up.
这篇关于如何将txt文件复制到远程计算机。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文