check the element parts for mandatory arrays

 var files = new List<string>() { "file2.jpg", "file1.jpg", "file1.png", "file2.bmp", "file3.png", "file1.bmp" };
        var exts = new[] { ".png", ".bmp", ".jpg" };

        var fileGroups = files
            .GroupBy(c => Path.GetFileNameWithoutExtension(c), v => Path.GetExtension(v))
            .Select(x => new { File = x.Key, MissingExts = exts.Except(x) })
            .Where(x=> x.MissingExts.Any());
        
        foreach(var group in fileGroups)
        {
            Console.WriteLine($"{group.File} {string.Join(' ', group.MissingExts)}");
        }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top