Friday, May 2, 2008

check file extention of a file using C# Sanjeewa sapumana

//check file extention of a file using C# Sanjeewa sapumana

private bool CheckMediaFileExtention()
{
string UploadedMediaFileName = btnFileUploadSelectMediaFile.FileName;
string[] file = new string[2];
file= UploadedMediaFileName.Split('.');

if (file.Length < 2)
{
return false;
}

string fileext = file[1].ToLower();

if (fileext == "wmv" || fileext == "avi")
{
return true;
}
else
{
TrMessage.Visible = true;
lblError.Text = Constants.MSG_Notifications_EnterSpecifiedMovieFormat.ToString();
lblError.CssClass = Structures.MessegeTypeCSS.MessageError.ToString();
return false;
}

}

No comments: