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();
精彩评论