如何将txt文件复制到远程计算机。

编程入门 行业动态 更新时间:2024-10-26 22:23:21
本文介绍了如何将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文件复制到远程计算机。

本文发布于:2023-10-17 02:51:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1499555.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   计算机   文件   txt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!