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客户端连接时,出现如下错误提示 ...
随机推荐
- JNDI Tutorial
Naming Concepts A fundamental facility in any computing system is the naming service--the means by w ...
- nuc950支持nand的mtd驱动的kernel修改
支持nand的mtd驱动的kernel修改 一.更新nanddriver文件 将新的nanddriver文件nuc900_nand.c放到kernel的drivers/mtd/nand目录下 二.修改 ...
- linux打包/解压-tar
tar命令: 压缩: tar -zcvf 打包的文件名.tar.gz 打包的文件 解压: tar -zxvf 要压缩的文件名.tar.gz
- phpstudy虚拟主机配置
<新手篇,开发者直接配置服务器配置文件即可> 很多时候我们从网下或通过其他途径下载源代码到本地Web目录下出现无法访问的案例: 具体的问题是程序路由路径方面做了手脚,把localhost当 ...
- 数据分页SQL语句的比较
建立表 CREATE TABLE [TestTable] ( , ) NOT NULL , ) COLLATE Chinese_PRC_CI_AS NULL , ) COLLATE Chinese_P ...
- testng,soket write error错误
网上解决手段: testng 工程报错java.net.SocketException SocketException: Software caused connection abort · Iss ...
- android:onclick属性
android:onclick属性设置点击时从上下文中调用指定的方法,此时给指定一个方法名.例如: xml中: <Button android:layout_width="wrap_c ...
- Ubuntu 下对ADT 添加别名(alias)
1:~$ vim .bashrc 2:在打开的.bashrc文件中加入: alias adt='./adt-bundle-linux-x86-20130729/eclipse/eclipse' 3:保 ...
- LeetCode _ Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...
- java疯狂演义----简单java IDE工具
file:commons package org.crazyit.editor.commons; import org.crazyit.editor.EditorFrame; import org.c ...