会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
玄新-术业有专攻
判断文件类型(文件的真正类型,不是根据扩展名判断),通过文件头来判断
bool
xx
=
false
;
//
default sFileName is not Exe or Dll File
System.IO.FileStream fs
=
new
System.IO.FileStream(sFileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
System.IO.BinaryReader r
=
new
System.IO.BinaryReader(fs);
string
bx
=
""
;
byte
buffer;
try
{
buffer
=
r.ReadByte();
bx
=
buffer.ToString();
buffer
=
r.ReadByte();
bx
+=
buffer.ToString();
}
catch
(Exception exc)
{
Console.WriteLine(exc.Message);
}
r.Close();
fs.Close();
if
(bx
==
"
7790
"
||
bx
==
"
8297
"
||
bx
==
"
8075
"
)
//
7790:exe,8297:rar,8075:pk
{
xx
=
true
;
}
Console.WriteLine(bx);
return
xx; dll:MZ
exe:MZ
rar:Rar
zip:PK
posted on
2006-12-19 10:19
玄新
阅读(
843
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
联系
管理