可靠的方法复制或.NET客户端移动远程文件? [英] Robust approach for copying or moving remote files from a .Net client?

查看:94
本文介绍了可靠的方法复制或.NET客户端移动远程文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows服务,监视远程共享的作业控制和作业输出文件和进程以及移动文件到压缩文件夹。

I have a Windows service that monitors remote shares for job control and job output files and processes and moves files to archive folders.

目前正在使用在System.IO命名空间中可用的方法(如Directory.Exists(),File.Move()等)来访问和移动这些文件我的最佳解决方案。

My best solution so far is using methods available in the System.IO namespace (like Directory.Exists(), File.Move(), etc) to access and move these files.

使用这种方法的问题是,如果远程计算机不在域中(它不是),我的服务,执行这些操作必须在还存在于远程(Windows)中的计算机上的用户帐户运行,并权限必须进行相应的设置为共享和远程和本地计算机无论在文件系统对象。

The issue with this approach is that if the remote computer is not in a domain (which it is not), my service that performs these operations must run under a user account that also exists on the remote (Windows) computer, and the permissions must be set accordingly for the share and the file system objects on both the remote and the local computers.

我关注可能出现的道路,如果环境发生变化,因为人们不知道这些依赖关系的问题。我宁愿建立一个更强大的解决方案。你有什么建议?

I am concerned about issues that might arise down the road if the environment changes because people are not aware of these dependencies. I'd much rather build a more robust solution. Do you have suggestions?

推荐答案

您将映射的网络路径使用NetUseAdd,WNetAddConnection2一种变型。

You would map the network path by using NetUseAdd, WNetAddConnection2 one of the variants.

http://pinvoke.net/default.aspx/netapi32.NetUseAdd

这篇关于可靠的方法复制或.NET客户端移动远程文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆