C# 使用其他域/用户名/密码将文件复制到另一个目录
在 c#2008 中, 我正在尝试将文件复制到目标路径(例如 \newserver\destinationFolder),该路径可以位于另一个域中或使用与当前用户不同的用户名/密码。在执行 File.Copy(...) 之前,如何指定这些新的网络凭据?
谢谢你!
In c# 2008,
I'm trying to copy a file to a destination path (for example \newserver\destinationFolder), that can be in another domain or using a different username/password than the current user. How can I specify these new network credentials before doing the File.Copy(...) ?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好问题,但我认为这是不可能的。我相信这种类型的文件从一个域复制到另一个域(没有建立信任)将被视为安全漏洞。
一些选项:
Good question but I dont think this is possible. I believe this type of file copy from one domain to another ( where there is not a trust set up) would be considered security hole.
Some options:
查看登录用户。这是它的 pinvoke 页面:
http://www.pinvoke.net/default.aspx /advapi32.logonuser
Look at LogonUser. Here's the pinvoke page for it:
http://www.pinvoke.net/default.aspx/advapi32.logonuser
地图驱动器 =>以本地用户身份复制文件=>取消映射驱动器。请查看此处:
MapDrive => Copy files as local user => UnmapDrive. Take a look here: