开发者

Search 0KB files in a folder C#

hi How can I find the files in a folder which are of size 0 KB using c#.

开发者_Python百科

Regards, Creator


    DirectoryInfo di = new DirectoryInfo("c:\\");
    FileInfo[] fiArr = di.GetFiles();
    foreach (FileInfo fri in fiArr)
        if (fri.Length < minimalSizeRequirement) 
          this.IamDoneFor();

Does this help?


Assuming you really want 0 byte files, perhaps this will do:

var di = new DirectoryInfo(@"c:\your\path");
FileInfo[] zeroSizeFiles = di.GetFiles("*.*")
    .Where(fi => fi.Length == 0)
    .ToArray();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜