C#获取文件夹中的所有内容 [英] C# get everything inside a folder

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

问题描述

大家好,我想在partiular文件夹exp:D:\ testfol中列出子文件夹中的所有文件,子文件夹,文件,并在列表框中添加。是否有可能??

如果可能的话可以提供一些例子?

谢谢,

hi guys, i wanna to list all files, subfolder, files inside subfolder at partiular folder exp: D:\testfol and add in listbox. is it possible??
if possible can provide some example??
thanks,

推荐答案

WPF已经与文件系统无关。你的问题是一个C#问题。在System.IO命名空间是一个Directory类,它有静态GetFiles和GetDirectories方法,你可以用来通过文件系统递归
WPF has nothing to do with the file system. Your question is a C# question. In the System.IO namespace is a Directory class, it has static GetFiles and GetDirectories methods, which you can use to recurse through the file system


你可以使用下面的代码



You can use the code below

foreach (System.IO.FileInfo fi in new System.IO.DirectoryInfo("D:\\testfol").GetFiles("*.*", System.IO.SearchOption.AllDirectories)
             {
// do something
             }


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

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