Directory.GetFiles 方法
Directory.GetFiles 方法
返回指定目录中文件的名称(包括其路径)。
命名空间: System.IO
程序集: mscorlib(mscorlib.dll 中)
EnumerateFiles和GetFiles方法的行为有所不同,如下所示: 当您使用EnumerateFiles,您可以开始之前,则返回整个集合 ; 枚举名称的集合当您使用GetFiles,您必须等待的名称,然后才能访问该数组要返回整个数组。因此,当您正在使用多个文件和目录、EnumerateFiles效率更高。
返回的文件名将追加到提供path参数。
此方法等同于GetFiles(String, String)用星号 (*) 指定为搜索模式。
path参数可以指定相对或绝对路径信息。相对路径信息被解释为相对于当前的工作目录。若要获取当前工作目录,请参阅GetCurrentDirectory。
不能保证返回的文件名称的顺序 ;使用Sort方法是否需要特定的排序顺序。
path参数不区分大小写。
通用 I/O 任务的列表,请参阅通用 I/O 任务。
- string[] files = Directory.GetFiles(this.TargetPath, this.TargetName + "*.sql");
- if (files == null || files.Length <= )
- {
- throw new Exception("还原数据库是获取源文件失败");
- }
Directory.GetFiles获取多个类型的文件
- var files = Directory.GetFiles("C:\\path", "*.*", SearchOption.AllDirectories)
- .Where(s => s.EndsWith(".mp3") || s.EndsWith(".jpg"));
Directory.GetFiles 方法的更多相关文章
- Directory的GetFiles方法
想实现一个功能 :比如多个业务审批流程公用一个审批表的时候,有一个提示审批信息的页面 ,点击该页面不同的业务审批流程记录的时候,跳转到不同业务流程的详细显示界面 额 这样说 貌似以后我自己也看不明白 ...
- C# Directory.GetFiles()获取文件时如果是根目录时有隐藏文件则报错的处理
如果Directory.GetFiles("d:\"),则由于回收站是隐藏文件而报错,怎么躲避这种错误呢, 我要了一种办法,只要遇到隐藏文件夹就跳过的方法: foreach (va ...
- C#中Directory.GetFiles() 函数的使用
C#中Directory.GetFiles(string path , string searchPattern, SearchOption searchOption ) 获取path目录中所有文件 ...
- 在.NET Framework中慎用DirectoryInfo.GetFiles方法
.NET Framework中的DirectoryInfo.GetFiles方法,可以在一个文件夹下通过通配符找出符合条件的文件. 我们首先在文件夹C:\DemoFolder下定义两个文件:demo. ...
- Ubuntu下 fatal error: Python.h: No such file or directory 解决方法
参考: fatal error: Python.h: No such file or directory Ubuntu下 fatal error: Python.h: No such file or ...
- numa.h:No such file or directory 解决方法
参考: numa.h:No such file or directory numa.h:No such file or directory 解决方法 Ubuntu: $ apt-get install ...
- 在c#中过滤通过System.IO.Directory.GetDirectories 方法获取的是所有的子目录和文件中的系统隐藏的文件(夹)的方法
//读取目录 下的所有非隐藏文件夹或文件 public List<FileItem> GetList(string path) { int i; string[] folders = Di ...
- C# Directory.GetFiles()获取多个类型格式的文件
第一种方式 System.IO.Directory.GetFiles()获取多个类型格式的文件 System.IO.Directory.GetFiles("c:\","( ...
- vsftpd出现“Response: 500 OOPS: cannot change directory”解决方法(转载)
vsftpd出现“Response: 500 OOPS: cannot change directory”解决方法 笔者用的Linux发行版本为centos当用FTP客户端连接时,出现如下错误提示 ...
随机推荐
- 单电机板机模型,f22
视频连接 http://v.youku.com/v_show/id_XMTI5MDEzMzIxMg==.html?from=y1.7-1.2 http://v.youku.com/v_show/id_ ...
- ecos之widget
weekbuy:widget.php<?php $setting['author']='zhang'; $setting['name']='周末购'; $setting['version']=' ...
- install pip3 for python 3.x
前言: 我目前使用的服务器为centos6.x 系统自带的python的版本为2.6.x,但是目前无论是学习还是使用python,python3都是首选,那么问题来了.---如何安装python3环境 ...
- with语句
<script type="text/javascript"> /* with语句:有了 With 语句,在存取对象属性和调用方法时就不用重复指定对象. 格式: wit ...
- android adb 常用指令
转自:http://www.cnblogs.com/playing/archive/2010/09/19/1830799.html Android 调试桥(adb)是多种用途的工具,该工具可以帮助你你 ...
- C# 文件创建时间,修改时间
System.IO.FileInfo fi = new System.IO.FileInfo(@"D:\site\EKECMS\skin\Grey\default#.html"); ...
- Jackknife,Bootstraping, bagging, boosting, AdaBoosting, Rand forest 和 gradient boosting的区别
引自http://blog.csdn.net/xianlingmao/article/details/7712217 Jackknife,Bootstraping, bagging, boosting ...
- poj 1819 Disks
http://poj.org/problem?id=1819 #include <cstdio> #include <cstring> #include <cmath&g ...
- Android 添加子视图(addView和setView)
我们在添加视图文件的时候有两种方式,一种是通过在xml文件定义layout,另一种方式是在java代码中动态生成布局文件. 在xml中定义的layout要想转化为view,需要使用到LayoutInf ...
- 华夏的理财30天A和华夏财富宝货币哪个收益比较好?
1.收益性比较 华夏理财30天A001057属于债券型基金,华夏财富宝货币000343属于货币型基金(活期宝,类似余额宝)收益不同 2.流动性 活期宝是可以随时取现的产品,30天A是有封闭期的产品,这 ...