Solved

Get file extensions of all the files on a drive

Posted on 2014-10-31
2
84 Views
Last Modified: 2014-11-01
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
Comment
Question by:JElster
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40416921
using System.IO;

...

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

Open in new window

0
 
LVL 1

Author Comment

by:JElster
ID: 40417118
How would I get the distinct values?
thx again
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question