var myfile = chkFile.value.ToLower();
var validExtension = "-c.doc";
label.innerText = myfile.EndsWith(validExtension) ? "Valid Format" : "Invalid Format";
UPDATE: Here is a test to check that the above code works:
C#6+ version
var files = new List<string> { "aaa.mp3", "aaa-c.mp3", "aAa-c.DoC", "aAa-c.doc" };
var validExtension = "-c.doc";
foreach (var file in files)
{
Console.WriteLine($"{file} is {(file.ToLower().EndsWith(validExtension) ? "Valid Format" : "Invalid Format")}");
}
Console.WriteLine("-- done --");
Console.ReadKey();
C# 5.0 or older:
var files = new List<string> { "aaa.mp3", "aaa-c.mp3", "aAa-c.DoC", "aAa-c.doc" };
var validExtension = "-c.doc";
foreach (string file in files)
{
Console.WriteLine(String.Format("{0} is {1}", file,
file.ToLower().EndsWith(validExtension)
? "Valid Format"
: "Invalid Format");
}
Console.WriteLine("-- done --");
Console.ReadKey();
Output:
aaa.mp3 is Invalid Format
aaa-c.mp3 is Invalid Format
aAa-c.DoC is Valid Format
aAa-c.doc is Valid Format
-- done --