Image extension validation c#
By Mash B
Logic to validate the image extension
You can make use of regular expression for simplicity of code
// the regex for an image
Regex imageFilenameRegex = new Regex(@"(.*?)\.(jpg|jpeg|png|gif)$");
if (imageFilenameRegex.IsMatch("Your FileName or Path here",RegexOptions.IgnoreCase))
{
// we have a valid filename
// .. do something ..
}
Image extension validation c# (1618 Views)