Check For valid PDF DOC

Lakhangarg
Posted by Lakhangarg under ASP.NET category on | Views : 3421
By using the below method we can check weather the selected file type is pdf or not.
we need to pass the ref id of the FileUpload control.
public static bool CheckValidPDFDOC(ref FileUpload file)
{
try
{
if (file.PostedFile.ContentType.ToLower() == "application/msword" || file.PostedFile.ContentType.ToLower() == "application/pdf")
{
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}

Thanks & Regards
Lakhan Pal Garg

Comments or Responses

Login to post response