I have n no. of files with many extension in local folder. I have to read count of total count of files from folder, again I have to check size of every single file, after verifying size.. .if we got any file size <0 byte . I have to report it as corrupted or could not open that file... so we can check that file by opening of every single files from folder...
I have tried following code to get count but with only one extension type. So how can get count of files from folder with all extension and how I can check size of file. And how I check whether that is corrupted. If I can open it then its sufficient.
public static int GetFileCount(string path, string searchPattern, SearchOption searchOption)
{
var fileCount = 0;
var fileIter = Directory.EnumerateFiles(path, searchPattern, searchOption);
foreach (var file in fileIter)
fileCount++;
return fileCount;
}
called above function as
GetFileCount(@"D:\Attachment", "*.png", SearchOption.AllDirectories);