How to Check Uploaded File Extension - ASP .Net

If you have fileUpload as your upload control
<input id="fileUpload" type="file" runat="server" />

This code sample check the file type if its an image. It can be altered for other file types as well. This example code is in C#.
HttpPostedFile myPostedFile=fileUpload.PostedFile;
if(myPostedFile!=null && myPostedFile.ContentLength>0)
{
FileInfo finfo = new FileInfo(myPostedFile.FileName);
string fileExtension = finfo.Extension.ToLower();
if (fileExtension != ".gif" && fileExtension != ".jpg" && fileExtension != ".jpeg" && fileExtension != ".png")
{
//show error message
return;
}
}