{
String ext = Path.GetExtension(fileName);
switch (ext.ToLower())
{
case ".gif": return true;
case ".png": return true;
case ".jpg": return true;
case ".jpeg": return true;
case ".bmp": return true;
default: return false;
}
}
i am calling this method by this way from another method -
if (fileUpload.HasFile) //here fileUpload is a asp.net FileUpload control
{
if ((CheckFileType(fileUpload.FileName))) { }
else { ErrorMessage.Text = "Please select a picture with a file
extension of either: .bmp .jpg .gif .png"; return; }
}