如何使用C#将文件从网络驱动器复制到本地驱动器? [英] How to copy file from network drive to local drive using C#?

查看:266
本文介绍了如何使用C#将文件从网络驱动器复制到本地驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络驱动器上有几组zip文件,其中包含登录该文件夹的凭据。文件每天都会添加。考虑到今天的日期,我需要编写一个程序将文件从网络驱动器复制到本地驱动器。我不知道如何开始它。我可以获得一些方法帮助吗?



我尝试过:



我不确定它是否正确,但我尝试了WindowsIdentity和Impersonation。

I have few set of zip files on network drive with credentials to login to the folder. Files gets added on daily basis. I need to write a program to copy file from network drive to the local drive considering today's date. I have no idea on how to start with it. Can I get some help on approach?

What I have tried:

I am not sure if it is right but i tried WindowsIdentity and Impersonation.

推荐答案

如果你要做很多事情,最好的解决办法是设置将网络设备上的共享作为本地计算机上的虚拟磁盘:这称为映射网络驱动器

如何在Windows 10中映射网络驱动器 [ ^ ]

然后你有一个驱动器号 - 例如Z: - 直接访问包含文件的文件夹你感兴趣的,你可以把它当作你自己电脑上的普通文件夹。如果远程计算机可用,Windows将在启动时重新建立链接。
If you are going to do this a lot, the best solution is to set up the share on the network device as a virtual disk on the local machine: this is called "mapping a network drive"
How to Map a Network Drive in Windows 10[^]
You then have a drive letter - "Z:" for example - which directly accesses the folder containing the files you are interested in, and you can treat is as a "normal" folder on your own computer. Windows will re-establish the link on power up, provided that the remote computer is available.


这篇关于如何使用C#将文件从网络驱动器复制到本地驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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