Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Please help me for the following problem,

I want to bind folder name , folder size , folder path (c drive only) into a gridview...
How do i do it...?

Thanks,
Rohit
Posted
Comments
Prasad_Kulkarni 18-Jun-13 6:32am    
Not clear Rohit!
If you can elaborate some more if possible with the code snippets if you've tried anything. You want to bind folder name, [which folder name, how you gonna find the folder]

1 solution

Try below code to bind directory information to GridView

C#
var path = @"c:/";
            var dirs = Directory.GetDirectories(path)
                .Select(x => new DirectoryInfo(x))
                .Select(x => new
                {
                    Size = x.GetFiles().Sum(c => c.Length),
                    Name = Path.GetDirectoryName(x.Name),
                    Path = x.FullName
                }).ToList();


Bind dirs object to GridView and use Size, Name and Path property to assign values.
 
Share this answer
 

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