I want to get the all the files sizes from the directory that I pass to the class and I want them to be sorted by their extension for example:
.exe:
file1.exe ....... 254KB
file1.exe ....... 544KB
file1.exe ....... 254KB
If their was any other extensions want them to be written like this
Below is the code I wrote so far but I don't know how to sort the data:
public FileTools(string directoryPath,string searchPattern)
{
DirectoryPath = directoryPath;
SearchPattern = searchPattern;
TotallFiles = new List<FileInfo>();
CalculateFiles();
}
private void CalculateFiles()
{
foreach (var item in new DirectoryInfo(this.DirectoryPath).GetFiles(SearchPattern,SearchOption.AllDirectories))
{
}
}
I want the FileInfo
objects filled in a List
and then sort and write them like the example.