如何使用C#将文件从网络驱动器复制到本地驱动器?

编程入门 行业动态 更新时间:2024-10-28 00:21:29
本文介绍了如何使用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#将文件从网络驱动器复制到本地驱动器?

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

发布评论

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

>www.elefans.com

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