I am looking to find the smallest amongst 2 files in a folder with respect to its size in KB.
So far I was trying the below logic to save the file size in an array, but I am not able to achieve this.
Is there a way to simply read the size of files in folder and find the smallest instead of reading size of each file and then saving their size in array and finding which is smallest?
I tried this and it does work. Unfortunately this is not how I need the result.
I have many files in the folder with multiple names:
I need to first filter the files with same name
then I need to find the type .pdf
then I need to find the smallest of them in size.
So, I have array of files (2 files with same name) and I need to find the smallest in size amongst these 2. So I cant use the GET Directory function.
we recommend to present all requiements always at the begin. So, we can adress more specific
we cannot derive what is meant with same name. Just share with us some samples. When it is about a common part of the name, then we would grouping the data
this we can already done on the file filtering
new DirectoryInfo("myFolderPath").GetFiles("*.pdf").OrderBy(Function (x) x.SizeInKB).First()
in general as done above.
Once you shared with us the requested details, then we will update our solution suggestion