日期:2014-05-18  浏览次数:20376 次

在上载时,如何过滤掉一些后缀名
在asp.net中如何编写程序.不让用户上传某些后缀名的文件.   如   ".bat "的

------解决方案--------------------
if(fileupload1.filename.substring(fileupload1.filename.lastindexof( ' ' '))!= "bat "
{
fileupload1.saveas();
}
------解决方案--------------------
string[] allowedException ={ ".doc ", ".txt " };
string fileException = System.IO.Path.GetExtension(fn).ToLower();
string fn = System.IO.Path.GetFileName(this.FindFile.PostedFile.FileName);
bool ok=false;
for (int j = 0; j < allowedException.Length; j++)
{
if (fileException == allowedException[j])
OK = true;
}
if (OK)
{

}