我是靠谱客的博主 懦弱山水,这篇文章主要介绍过滤指定目录下指定后缀名文件,现在分享给大家,希望可以做个参考。

对于很多应用功能,有时需要获取指定目录下的指定后缀名文件以实现批处理。以下为事例代码:取到的文件放入动态数组中……
/// <summary> /// 获取某一扩展名的文件集合 /// </summary> /// <param name="dictoryName">目录名</param> /// <param name="fiterName">扩展名</param> /// <returns>文件名集合</returns> public List<string> View(string dictoryName,string fiterName) { List<string> ViewFileNameLst = new List<string>(); if (!Directory.Exists(dictoryName)) { return ViewFileNameLst; } DirectoryInfo dirInfo=new DirectoryInfo(dictoryName); FileInfo[] fileInfs= dirInfo.GetFiles(); foreach(FileInfo fInfo in fileInfs) { //过滤指定后缀名文件 if(fInfo.Name.EndsWith(fiterName)) { ViewFileNameLst.Add(System.IO.Path.GetFileNameWithoutExtension(fInfo.FullName)); } } return ViewFileNameLst; }

 

转载于:https://www.cnblogs.com/wylaok/archive/2012/07/06/2579456.html

最后

以上就是懦弱山水最近收集整理的关于过滤指定目录下指定后缀名文件的全部内容,更多相关过滤指定目录下指定后缀名文件内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(99)

评论列表共有 0 条评论

立即
投稿
返回
顶部