从子文件夹复制特定文件类型 [英] Copy Specific file type from subfolders

查看:35
本文介绍了从子文件夹复制特定文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手,我正在尝试构建一个控制台应用程序来复制特定文件类型(例如* .txt),该文件类型嵌套在子文件夹中以复制到另一个目录.

I am new to C# and I am trying to build a console application to copy a specific file type .e.g *.txt that is nested within subfolders to be copied to another directory.

目录看起来像这样 C:\ V1.1 \ Folder _ * \ Folder \ Folder \ Folder \ Filetype.txt

* 表示今天的日期

如何获取与该模式匹配的文件列表?

How would I get a list of files matching that pattern?

推荐答案

尝试类似的方法.

var path = String.Format(@"C:\V1.1\Folder_{0}\Folder\Folder\Folder",
            DateTime.ToString("dd-MM-yyyy"))

 DirectoryInfo di = new DirectoryInfo(path);
 var files=di.GetFiles("*.txt", SearchOption.AllDirectories)

您可以查看此网站,以获取更多信息.

You can check this site out for more information.

这篇关于从子文件夹复制特定文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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