c# - 如何从目录中获取子文件夹中的文件

标签 c# asp.net directory

您好,我必须从目录中的指定路径获取文件。这是我写的方法,但是我没有从子文件夹中获取文件。

Private void getfiles(){
Directoryinfo info = new Directoryinfo(configurationmanager.appsettings["Targetroot"].tostring ());
if (info.exists){
     Gvfiles.datasource = info.GetFiles();
     Gvfiles.databind();
   }
}

最佳答案

您需要包含 SearchOption.AllDirectories。

例子:

info.GetFiles("*", SearchOption.AllDirectories);

引用: http://msdn.microsoft.com/en-us/library/ms143327(v=vs.80).aspx

并且: http://msdn.microsoft.com/en-us/library/ms143448(v=vs.80).aspx

关于c# - 如何从目录中获取子文件夹中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11775655/

相关文章:

c# - 将系统默认上下文菜单添加到无边框 Windows 窗体

c# - 如何从 Entity Framework 中的存储过程中获取数据作为数据集

asp.net - 如何摆脱难看的asp:菜单闪烁?

asp.net - Azure Web 角色 - 最大出站 http 连接数

file - 如何从 pyspark 中的 hdfs 获取目录的文件名列表?

c++ - 头文件基本上是预先编写的类吗? C++

c# - 如何在C#中创建一个md5文件

c# - 如何在没有Kinect的情况下将深度帧映射到彩色帧

c# - 即时生成或更新 OperationContract

directory - Plone 文件夹限制