This probably isn't the greatest solution, but you could determine your file
extentions in the following way:
string allowedFormats = "|gif|jpg|doc|txt|ppt|xls|htm|html|";
string x = "file.jpg";
Response.Write(x.Split(new char[] {'.'}, 2)[1] + "<br>");
if (allowedFormats.IndexOf("|" + x.Split(new char[] {'.'}, 2)[1] + "|") >
0 )
{
Response.Write("this extension is ok<br>");
}
else
{
Response.Write("this extension is NOT ok<br>");
}
string y = "file.jpg.ext";
Response.Write(y.Split(new char[] {'.'}, 2)[1] + "<br>");
if (allowedFormats.IndexOf("|" + y.Split(new char[] {'.'}, 2)[1] + "|") >
0 )
{
Response.Write("this extension is ok<br>");
}
else
{
Response.Write("this extension is NOT ok<br>");
}
The first filename, variable "x" - will print "this extension is ok" where
variable "y" will print "this extension is NOT ok"