开发者

Search 0KB files in a folder C#

开发者 https://www.devze.com 2023-02-28 07:22 出处:网络
hi How can I find the files ina folder which are of size 0 KB using c#. 开发者_Python百科Regards, CreatorDirectoryInfo di = new DirectoryInfo(\"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

精彩评论

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