VB c# beginner here. I am using the following snippet of code to list out all the videos in a directory.
var files = Directory
.GetFiles("D:\\Movies", "*.*", SearchOption.AllDirectories)
.Where(s => s.ToLower().EndsWith(".mp4") || s.ToLower().EndsWith(".mkv") || s.ToLower().EndsWith(".avi"));
Now the challenge is to exclude those videos which have 'sample' word in their names.
I tried adding .Where(s => s != "sample.avi");
at the end but it doesn't seem to work.
also when I do .Where(s => s.Contains("sample");
, I am able to list out all the files which have the word 'sample' in their names.
Also is it possible to delete those names from the files
array or enum whatever that is ? I don't think that works as an array because finding the count doesn't work like files.Count
/ files.Length
.
I think my understanding of enums and string is a little weak here. Please guide.