private bool IsAllowedExtension(HttpPostedFile hifile)
{
bool ret = false; System.IO.FileStream fs = new System.IO.FileStream(hifile.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader r = new System.IO.BinaryReader(fs);
string fileclass = "";
byte buffer;
try
{
buffer = r.ReadByte();
fileclass = buffer.ToString();
buffer = r.ReadByte();
fileclass += buffer.ToString();
}
catch
{
return false;
}
r.Close();
fs.Close();
/*文件扩展名说明
*7173 gif
*255216 jpg
*13780 png
*6677 bmp
*239187 txt,aspx,asp,sql
*208207 xls.doc.ppt
*6063 xml
*6033 htm,html
*4742 js
*8075 xlsx,zip,pptx,mmap,zip
*8297 rar
*01 accdb,mdb
*7790 exe,dll
*5666 psd
*255254 rdp
*10056 bt种子
*64101 bat
*/ String[] fileType = { "", "", "", "", "", "", "", "", "" }; for (int i = ; i < fileType.Length; i++)
{
if (fileclass == fileType[i])
{
ret = true;
break;
}
}
return ret;
}

最新文章

  1. vs使用
  2. 第37课 深度解析QMap与QHash
  3. java jar包收集
  4. 如何查看经过编码的cookie?
  5. C# 多线程详解 Part.01(UI 线程、子线程)
  6. Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper bfs
  7. Nginx在Windows系统和Linux系统下的重启
  8. 5方与5W
  9. 单件模式Singleton来控制窗体被重复或多次打开
  10. SQL语句优化(转摘)
  11. poj 3082多边形相交 &#39;Roid Rage
  12. Boosting 和梯度Boosting
  13. css 修改默认滚动条样式
  14. Jenkins 配置 Git 错误解决:CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
  15. java 写一个JSON解析的工具类
  16. ASP.NET Core Middleware管道介绍
  17. Kubernetes Ingress 学习
  18. 一次关于()=&gt;({})的使用
  19. 前端开发面试题-CSS(转载)
  20. Linux Install redis

热门文章

  1. iOS开发系列-应用程序之间跳转
  2. 什么是Java中的自动拆装箱
  3. 随笔记录 MBR扇区故障系统备份与还原 2019.8.7
  4. C#利用资源文件设置软件自适应多语言
  5. Elasticsearch.net一些开发笔记
  6. 数据库MySQL--条件查询/排序查询
  7. matlab中乘法和点乘以及除法和点除的联系是什么?
  8. C/C++ nullptr
  9. 【Servlet】Servlet监听器
  10. 阿里云SaaS加速器“宜搭”发布宜搭Plus提升6倍研发效率