zoukankan
html css js c++ java
遍历文件夹所有文件(示例)
//
要引用
using
System.Collections.Specialized;
public
StringCollection GetAllFiles(
string
rootdir)
{
StringCollection result
=
new
StringCollection();
GetAllFiles(rootdir, result);
return
result;
}
void
GetAllFiles(
string
parentDir, StringCollection result)
{
string
[] dir
=
System.IO.Directory.GetDirectories(parentDir);
for
(
int
i
=
0
; i
<
dir.Length; i
++
)
GetAllFiles(dir[i], result);
string
[] file
=
System.IO.Directory.GetFiles(parentDir);
for
(
int
i
=
0
; i
<
file.Length; i
++
)
result.Add(file[i]);
}
private
void
button1_Click(
object
sender, EventArgs e)
{
string
indexPath
=
@"
c:\temp
"
;
StringCollection sc
=
GetAllFiles(indexPath);
foreach
(
string
s
in
sc)
{
this
.listBox1.Items.Add(s);
}
}
作者:
菩提树下的杨过
出处:
http://yjmyzz.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
linux常用脚本
shell学习笔记
Linux常用命令List
Centos7部署Zabbix
centos7安装nagios步骤
nagios报错HTTP WARNING: HTTP/1.1 403 Forbidden解决方法
U盘安装CentOS7
Thread线程控制之sleep、join、setDaemon方法的用处
EfficientDet框架详解 | 目前最高最快最小模型,可扩缩且高效的目标检测(附源码下载)
ubuntu18.04 安装多版本cuda ,原来版本为9.0,在新增8.0
原文地址:https://www.cnblogs.com/yjmyzz/p/1019100.html
最新文章
vue双向数据绑定v-model
微信小程序使用Graphql请求接口封装(wxGraphql.js)
微信公众号H5页面跳转微信小程序(微信开放标签wx-open-launch-weapp)
ES5和ES6的区别
Vue上传材料(使用Element Upload组件)
Js 数组通过时间排序
git常用命令
CSS媒体查询
浅谈Vue中Slot以及slot-scope
MPI初学-安装及OpenMPI函数说明
热门文章
LeetCode Problem 2:Two Sum
LeetCode Problem 9:Palindrome Number回文数
LeetCode Problem 35:Search Insert Position
LeetCode Problem 136:Single Number
LeetCode Problem 169: Majority Element查找多数元素
机器学习--判别式模型与生成式模型
机器学习有监督学习之--回归
高性能MySQL--索引学习笔记(原创)
Linux服务器性能查看分析调优
linux_cmd_list_0
Copyright © 2011-2022 走看看