//读取目录 下的所有非隐藏文件夹或文件
public List<FileItem> GetList(string path)
{
int i;
string[] folders = Directory.GetDirectories(path);
string[] files = Directory.GetFiles(path);
List<FileItem> list = new List<FileItem>();
foreach (string s in folders)
{ FileItem item = new FileItem();
DirectoryInfo di = new DirectoryInfo(s);
string[] w = di.Name.Split(new char[] { '#' });
if (w.Length == 1)
{
item.Name = di.Name;
}
else
{
item.Name="";
for(i=1;i<w.Length;i++)
item.Name=item.Name+w[i];
}
item.FullName =rlocaltourlconver(di.FullName);
item.CreationDate = di.CreationTime;
item.Size =(float)FileSize(s)/(1024);
item.IsFolder = true;
if ((new FileInfo(s).Attributes & FileAttributes.Hidden) ==0)//过滤隐藏文件夹
{
list.Add(item);
} }
foreach (string s in files)
{
FileItem item = new FileItem();
FileInfo fi = new FileInfo(s);
string[] w = fi.Name.Split(new char[] { '#' });
if (w.Length == 1)
{
item.Name = fi.Name;
}
else
{
item.Name = "";
for (i = 1; i < w.Length; i++)
item.Name = item.Name + w[i];
}
item.FullName = rlocaltourlconver(fi.FullName); item.CreationDate = fi.CreationTime;
item.IsFolder = true;
item.Size = (float)fi.Length/(1024);
item.FileCount = 0;
if ((new FileInfo(s).Attributes & FileAttributes.Hidden) == 0)//过滤隐藏文件
{
list.Add(item);
}
}
return list;
}

参考链接:1,2

在c#中过滤通过System.IO.Directory.GetDirectories 方法获取的是所有的子目录和文件中的系统隐藏的文件(夹)的方法的更多相关文章

  1. System.IO.Directory类

    1.参考的博客:System.IO.Directory类和System.DirectoryInfo类(http://blog.sina.com.cn/s/blog_614f473101017du4.h ...

  2. 【C#遗补】获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPath的区别

    原文:[C#遗补]获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPa ...

  3. System.IO.Directory.Delete目录删除

    在程序运行的时候,如果直接获取一个目录路径,然后执行删除(包括子目录及文件): System.IO.Directory.Delete(path,true); 或者 System.IO.Director ...

  4. System.IO.Directory.cs

    ylbtech-System.IO.Directory.cs 1.返回顶部 1. #region 程序集 mscorlib, Version=4.0.0.0, Culture=neutral, Pub ...

  5. System.IO中的File、FileInfo、Directory与DirectoryInfo类(实例讲解)

    一.建立的文件夹(对这些文件进行以上四个类的操作): 父目录: 父目录的子目录以及父目录下的文件: 子目录下的文件: 二.效果图 三.代码实现 using System; using System.I ...

  6. 详解C#中System.IO.File类和System.IO.FileInfo类的用法

    System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间.下面通过程序实例来介绍其主要属性和方法. (1) 文件打开 ...

  7. System.IO

                 I/O       1.文件操作:File (1)void AppendAllText(string path, string contents) (2)bool Exist ...

  8. System.IO在不存在的路径下创建文件夹和文件的测试

    本文测试System.IO命名空间下的类,在不存在的路径下创建文件夹和文件的效果: 首先测试创建文件夹: System.IO.Directory.CreateDirectory(@"C:\A ...

  9. System.IO之内存映射文件共享内存

    内存映射文件是利用虚拟内存把文件映射到进程的地址空间中去,在此之后进程操作文件,就 像操作进程空间里的地址一样了,比如使用c语言的memcpy等内存操作的函数.这种方法能够很好的应用在需要频繁处理一个 ...

随机推荐

  1. js new关键字

    实现new 关键字只需4步 1. 声明一个对象: 2. 把这个对象的__proto__ 指向构造函数的 prototype; 3. 以构造函数为上下文执行这个对象: 4. 返回这个对象. 简洁的代码示 ...

  2. http——解读梳理

    (1)在客户端与服务器建立准确连接传输之前,先讲一讲三次握手 第一次握手:建立连接时,客户端发送syn包[同步序列编号(Synchronize Sequence Numbers).是TCP/IP建立连 ...

  3. Day24-Ajax操作、图片验证码、KindEditor使用-转

    参考源:http://blog.csdn.net/fgf00/article/details/54917439 三.Ajax操作 ajax操作基于浏览器的xmlHttpRequest对象,IE低版本是 ...

  4. 解题:HNOI 2013 Cards

    题面 除了不洗牌以外,每种洗牌方式的每个循环里的颜色必须一样,然后大力背包一下就好了.最后记得把不洗牌的方案也算进去 #include<cstdio> #include<cstrin ...

  5. HDU 4280 Island Transport(网络流,最大流)

    HDU 4280 Island Transport(网络流,最大流) Description In the vast waters far far away, there are many islan ...

  6. Dist

    Description 数据范围:\(1<=n<=10^5,1<=k<=18,1<=k_i<=10^7,\sum |s_i|<=3*10^5\) Soluti ...

  7. 【转】METADATATYPE的使用,MVC的MODEL层数据验证

    http://www.cnblogs.com/chshnan/archive/2011/07/08/2100713.html MetadataType的使用,MVC的Model层数据验证指定要与数据模 ...

  8. HTTP记录-HTTP介绍

    超文本传输协议 (HTTP-Hypertext transfer protocol) 是一种详细规定了浏览器和万维网服务器之间互相通信的规则,通过因特网传送万维网文档的数据传送协议.是一个应用程序级的 ...

  9. LFS、BLFS、ALFS、HLFS的区别

    转自:http://www.ha97.com/3927.html Linux From Scratch (LFS) 及其后代代表一种新方法,向用户揭示 Linux 操作系统是如何工作的.LFS 基于这 ...

  10. bzoj千题计划184:bzoj1261: [SCOI2006]zh_tree

    http://www.lydsy.com/JudgeOnline/problem.php?id=1261 dp[l][r][dep]  区间[l,r]内的节点,根在dep层的最小代价 枚举根i,dp[ ...