• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 104
  • Last Modified:

Get file extensions of all the files on a drive

How can I write a program to transverse/recusive a drive  (C:\) and return a list of all the file extensions?

I know I can use Path.GetExtension
0
JElster
Asked:
JElster
1 Solution
 
käµfm³d 👽Commented:
using System.IO;

...

foreach (string filename in Directory.EnumerateFiles(@"C:\", "*.*", SearchOption.AllDirectories))
{
    Console.WriteLine(Path.GetExtension(filename));
}

Open in new window

0
 
JElsterAuthor Commented:
How would I get the distinct values?
thx again
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now