C#获取项目指定目录下文件的方法
作者:Regina 时间:2023-04-19 07:15:26
本文实例讲述了C#获取项目指定目录下文件的方法。分享给大家供大家参考。具体如下:
public List<FileInfo> GetFiles() {
string path = string.Concat(System.AppDomain.CurrentDomain.BaseDirectory,"Files\\");
//获取项目物理路径
string[] fileType=new string[]{"pdf\\","pps\\","xls\\"};
string[] directoryFiles = new string[] { };
List<FileInfo> fileInfoList = new List<FileInfo>();
for (int f = 0; f < fileType.Count(); f++) {
path = path + fileType[f];
directoryFiles=System.IO.Directory.GetFiles(path);
for(int d=0;d<directoryFiles.Count();d++){
FileInfo fileInfo = new FileInfo(directoryFiles[d]);
fileInfoList.Add(fileInfo);
}
}
return fileInfoList;
}
silverlight获取xap路径:Application.Current.Host.Source.AbsoluteUri
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,获取,目录,文件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C# TabControl手动触发DrawItem的实现
2023-12-27 17:01:27
Java数组传递及可变参数操作实例详解
2023-08-26 21:21:59
![](https://img.aspxhome.com/file/2023/0/77160_0s.png)
详解 Java Maximum redirects (100) exceeded
2023-08-05 21:03:47
Windows窗体的.Net框架绘图技术实现方法
2022-06-29 13:32:23
Java线程池必知必会知识点总结
2021-07-30 13:08:02
![](https://img.aspxhome.com/file/2023/4/113514_0s.png)
Intellij IDEA 阅读源码的 4 个绝技(必看)
2023-06-14 11:23:16
![](https://img.aspxhome.com/file/2023/9/106109_0s.png)
使用Java 实现一个“你画手机猜”的小游戏
2021-06-03 19:19:27
![](https://img.aspxhome.com/file/2023/8/76258_0s.gif)
非常适合新手学生的Java线程池超详细分析
2023-03-03 11:59:54
Java BigDecimal除法精度和格式化输出方式
2023-01-06 01:03:42
java FastJson的简单用法
2022-07-07 23:51:47
C#多线程系列之线程通知
2023-09-13 17:08:03
![](https://img.aspxhome.com/file/2023/4/96304_0s.jpg)
Android的ListView多选删除操作实现代码
2023-06-25 22:24:38
![](https://img.aspxhome.com/file/2023/4/93274_0s.jpg)
Java Vector实现班级信息管理系统
2023-11-25 03:09:09
![](https://img.aspxhome.com/file/2023/3/60233_0s.jpg)
如何在Spring Boot中使用MQTT
2023-10-08 20:39:13
Android自定义View实现BMI指数条
2021-08-28 18:12:12
![](https://img.aspxhome.com/file/2023/0/103920_0s.jpg)
Android车载多媒体开发MediaSession框架示例详解
2022-08-10 19:49:20
![](https://img.aspxhome.com/file/2023/1/116161_0s.jpg)
Java Web 简单的分页显示实例代码
2023-04-19 20:06:21
![](https://img.aspxhome.com/file/2023/1/102651_0s.jpg)
Unity实现枚举类型中文显示
2023-02-22 12:00:28
![](https://img.aspxhome.com/file/2023/1/100151_0s.gif)
Java基于Socket实现HTTP下载客户端
2022-07-06 01:02:30
![](https://img.aspxhome.com/file/2023/7/114037_0s.png)
mybatis教程之延迟加载详解
2023-02-19 12:45:18
![](https://img.aspxhome.com/file/2023/7/65607_0s.png)