获取要创建的所有文件和文件夹 [英] Get all files and folders to form

查看:79
本文介绍了获取要创建的所有文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在布局中将所有文件夹放到我的表格中Tiles。

之后,当我点击任何文件夹时,它会显示子文件夹和文件。

你能告诉我任何解决方案吗?

谢谢!

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!

推荐答案

怎么样'文档' [ ^ ]?


如果你只想获取目录,那么System.IO命名空间就是你的朋友。您可以读取目录,并在每个目录中获取文件。



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



您可以使用此代码枚举文件系统中的目录。



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.

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.

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);
}





..对每个目录重复相同的过程,并为包含每个元素的每个元素处理Click事件下一个目录的名称。



..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.


这篇关于获取要创建的所有文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆