Reputation: 9950
Here's a piece of code:
if (fbFolderBrowser.ShowDialog() == DialogResult.OK)
{
originalFiles = Directory.GetFiles(fbFolderBrowser.SelectedPath);
supportedFiles = originalFiles.Where(s => s.EndsWith(".jpg") || s.EndsWith(".bmp") || s.EndsWith(".tiff") || s.EndsWith(".jpeg") || s.EndsWith(".gif")).ToArray();
}
What if in the directory selected, the files' extensions are hidden? Does it mean I won't be able to use "EndsWith?"
What would be the correct way to KNOW the file extensions?
Upvotes: 0
Views: 658
Reputation: 85046
You will still see the extension if you access the directory from code. The "hidden" extension only hides it when browsing to files through the UI.
Upvotes: 1
Reputation: 887365
Hiding file extensions is a behavior of the UI run by the Windows shell.
It has no effect on your code; all actual filepaths will still have extensions.
Bonus: Look at the Path.GetExtension()
method.
Upvotes: 4