如何获取文件夹及其子文件夹中的所有文件名 [英] how to get all file name in a folder and its subfolder
本文介绍了如何获取文件夹及其子文件夹中的所有文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
如何获取文件夹中的所有文件名及其在web中的子文件夹。我正在使用此代码,但它无法读取该文件夹中其他文件夹内的文件名
(例如-D:\\Test \\ Application \\ common)
Hello,
how to get all file name in a folder and its subfolder in web .I am using this code but it cant read file name which is inside other folder in this folder
(e.g-D:\\Test\\Application\\common)
DataTable ord = new DataTable("Table");
DataColumn c = new DataColumn();
ord.Columns.Add(new DataColumn("Number", Type.GetType("System.Int32")));
ord.Columns.Add(new DataColumn("Name", Type.GetType("System.String")));
ord.Columns.Add(new DataColumn("Size", Type.GetType("System.String")));
ord.Columns.Add(new DataColumn("CreationTime", Type.GetType("System.String")));
ord.Columns.Add(new DataColumn("FolderName", Type.GetType("System.String")));
string path = "D:\\Test\\Application";
DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo flInfo in dir.GetFiles())
{
count++;
String name = flInfo.Name;
long size = flInfo.Length;
DateTime creationTime = flInfo.CreationTime;
ord.Rows.Add(count, name, size, creationTime,"");
}
推荐答案
请参阅..
http://www.dotnetperls.com/directory-getfiles [ ^ ]
http://msdn.microsoft.com/en-us/library/07wt70x2(v = vs.110).aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ system.io.file.delete(v = vs.110).aspx [ ^ ]
See..
http://www.dotnetperls.com/directory-getfiles[^]
http://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx[^]
http://msdn.microsoft.com/en-us/library/system.io.file.delete(v=vs.110).aspx[^]
您好,点击下方获取答案,>
http://www.aspdotnet-suresh.com/2013/08/c-get-all-files-from-folder-and .html [ ^ ]
Hi, click below to get your answer,
http://www.aspdotnet-suresh.com/2013/08/c-get-all-files-from-folder-and.html[^]
这篇关于如何获取文件夹及其子文件夹中的所有文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文