1、做事干净、讲究效率 2、说话干脆、注重感情
首页
社区
联系
管理
判断文件类型(文件的真正类型,不是根据扩展名判断),通过文件头来判断
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 @
2005-01-18 08:33
jhtchina
阅读(4633) 评论(
7
)
编辑
收藏
刷新评论
刷新页面
返回顶部
程序员问答社区,解决您的IT难题
博客园首页
博问
新闻
闪存
程序员招聘
知识库
公告
http://count.51yes.com/