Here i am retrieving minimum size of a text file inside a directory.But it gives 0 as a minimum size.But there is no 0 kb file inside that directory.
var queryList3Only= (from i in di.GetFiles("*.txt", SearchOption.AllDirectories)
select i.Length / 1024).Min();
dest.WriteLine(queryList3Only.ToString()+" Kb");
Any Suggestion?
you need to select doubles not int's. if filesize is < 1024 then you will end with size 0
var queryList3Only= (from i in di.GetFiles("*.txt", SearchOption.AllDirectories)
select (double)i.Length / 1024).Min();
If you have any files less that 1024 bytes then they will appear as zero as your integer division will be truncated.
1023 / 1024 = 0
You may find casting the values to doubles will get you an answer between 0 and 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With