如何在c#中将文件从一个系统传输到另一个系统? [英] how to transfer a files from one system to another system in c#?
本文介绍了如何在c#中将文件从一个系统传输到另一个系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在两个系统之间传输任何类型的文档(例如,文字,pdf,视频),并自动存储在客户端系统的指定文件夹中。请使用 System.IO;
I need to transfer any type of documents (ex words, pdf, video) between two systems and store automatically in specified folder of client system. Please do the needful
推荐答案
using System.IO;string sourcePath = @"D:\test";string targetPath = @"D:\test_new";if (!Directory.Exists(targetPath)){ Directory.CreateDirectory(targetPath);}foreach (var srcPath in Directory.GetFiles(sourcePath)){ //Copy the file from sourcepath and place into mentioned target path, //Overwrite the file if same file is exist in target path File.Copy(srcPath, srcPath.Replace(sourcePath, targetPath), true);}
这篇关于如何在c#中将文件从一个系统传输到另一个系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文