Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)

C#
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,"");
        }
Posted
Updated 8-Dec-14 20:36pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900