Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i wanna get all folders to my form within the layout is "Tiles".
After that, when i click any folder, it will show sub-folder and files.
Can you give to me any solution?
Thanks!
Posted
Comments
Afzaal Ahmad Zeeshan 16-Sep-14 12:17pm    
You think this is a "Give me the code" site?
user8x86 16-Sep-14 12:20pm    
Not "Give me the code". I need a conduction.
Afzaal Ahmad Zeeshan 16-Sep-14 12:23pm    
Have a look at my answer, I have given the basics about the code that you will be using. You can build your application using the resources from MSDN.
ZurdoDev 16-Sep-14 12:17pm    
Where are you stuck?
user8x86 16-Sep-14 12:23pm    
when i loaded folders to my textbox. I couldn't double click to show files and subfolders

What about 'The Documentation'[^] ?
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 16-Sep-14 16:27pm    
5ed, but I fixed your typo. Hope you won't mind...
—SA
CPallini 17-Sep-14 0:32am    
Thank you both for voting and fixing.
If you just want to get the directories, then the System.IO namespace would be your friend. You can read the directories and inside each directory you can get the files.

http://msdn.microsoft.com/en-us/library/system.io(v=vs.110).aspx[^] (System.IO at MSDN)

You can use this code, to enumerate the directories inside your file system.

C#
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));

// since it is a list of strings, 
foreach (string dir in dirs) 
{
   Console.WriteLine(dir);
   // or if it is an ASP.NET project
   Response.Write(dir);
}


After this, you can get the files in that directory.

C#
List<string> files = new List<string>(Directory.EnumerateFiles(dirPath));

// since it is a list of strings, 
foreach (string file in files) 
{
   Console.WriteLine(file);
   // or if it is an ASP.NET project
   Response.Write(file);
}


..repeat the same process for each of the directory and handle the event of Click for each element that contains the name of the next directory.
 
Share this answer
 
v2
Comments
user8x86 16-Sep-14 12:51pm    
Thanks for showing my stupid!

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