Determine if a File Type will be blocked programmatically
If you are writing custom code that uploads a document into a SharePoint Document Library, you must abide by the same rules as if uploading the document through the SharePoint UI. Therefore, if the user tries to upload a document that is of a restricted file type, they will receive an error.
“The following file(s) have been blocked by the administrator: filename”.
You can control which files are blocked from Central Administration. Browse to Operations > Blocked File Types (Under the Security Configuration Group)
When uploading files programmatically, you do not have to write any code to check which file types are allowed before uploading a file. SharePoint will return the same error if you leave your code as-is and you try to upload a blocked file type. Be sure to handle this exception properly so your user knows what is going on.
If you wish to check beforehand you can do so by reading through SPContext.Current.Site.WebApplication.BlockedFileExtensions
Here is a rough example: