Monday, October 26, 2009
Restrict file selected in FileUpload control in Asp.Net
private bool IsValidFile(string filePath)
{
bool isValid = false;
string[] fileExtensions = { ".bmp", ".jpg", ".png", ".gif", ".jpeg", ".doc", ".docx", ".txt", ".rtf", ".RTF", ".DOC", ".DOCX", ".TXT", ".BMP", ".JPG", ".PNG", ".JPEG" };
for (int i = 0; i < fileExtensions.Length; i++)
{
if (filePath.Contains(fileExtensions[i]))
{
isValid = true;
}
}
return isValid;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment