Tag Archives: file sizes

Use LINQ to list files and file sizes in a directory in C#

When you enter a directory name and click the List Files button, the following code lists files and file sizes in the directory you entered in the text box. // List the files in the selected directory and their sizes. … Continue reading

Posted in files, LINQ | Tagged , , , , , , , , , , , , , | Leave a comment

Format file sizes in KB, MB, GB, and so forth in C#

This example shows how to format file sizes in KB, MB, GB, and so forth. It defines two extension methods that convert numeric values into strings representing a number of bytes in bytes, KB, MB, and so forth. The first … Continue reading

Posted in algorithms, files, mathematics | Tagged , , , , , , , , , , , , , , , , | 4 Comments