Skip to content

Instantly share code, notes, and snippets.

@alvarosinmarca
Last active March 31, 2023 11:02
Show Gist options
  • Save alvarosinmarca/e4852d89bdf35c6ad3b6c0560aa63c46 to your computer and use it in GitHub Desktop.
Save alvarosinmarca/e4852d89bdf35c6ad3b6c0560aa63c46 to your computer and use it in GitHub Desktop.
GetExtensionsInFolder with C#
var pathSelected = "D:\\TORRENTS";
DirectoryInfo directorySelected = new DirectoryInfo(pathSelected);
var filesInfo = directorySelected.GetFiles("*", SearchOption.AllDirectories).ToList();
List<string> extensions = new List<string>();
foreach (var file in filesInfo)
{
if (!extensions.Contains(file.Extension))
{
extensions.Add(file.Extension);
Console.WriteLine(file.Extension);
}
}
Console.ReadLine();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment