资源简介
即使文件后缀被乱改也可以通过查看二进制文件查出文件的匹配类型
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.InteropServices;
namespace abc
{
///
/// 作者:何展邦 QQ:278014296
///
class Program
{
static Dictionary dict = new Dictionary();
static void addDictionary()
{
string source= @“JPEG (jpg),FFD8FF
PNG (png),文件头:89504E47
GIF (gif),文件头:47494638
TIFF (tif),文件头:49492A00
Windows Bitmap (bmp),文件头:424D
CAD (dwg),文件头:41433130
Adobe Photoshop (psd),文件头:38425053
Rich Text Format (rtf),文件头:7B5C727466
xml (xml),文件头:3C3F786D6C
HTML (html),文件头:68746D6C3E
Email [thorough only] (eml),文件头:44656C69766572792D646174653A
Outlook Express (dbx),文件头:CFAD12FEC5FD746F
Outlook (pst),文件头:2142444E
MS Word/Excel (xls.or.doc),文件头:D0CF11E0
MS Access (mdb),文件头:000100005374616e64617264204a
WordPerfect (wpd),文件头:FF575043
Postscript (eps.or.ps),文件头:252150532D41646F6265
Adobe Acrobat (pdf),文件头:255044462D312E
Quicken (qdf),文件头:AC9EBD8F
Windows Password (pwl),文件头:E3828596
ZIP Archive (zip),文件头:504B0304
RAR Archive (rar),文件头:52617221
Wave (wav),文件头:52494646dad3010057415645
AVI (avi),文件头:524946462619000041564920
Real Audio (ram),文件头:2E7261FD
Real Media (rm),文件头:2E524D46
MPEG (mpg),文件头:000001BA
MPEG (mpg),文件头:000001B3
Quicktime (mov),文件头:6D6F6F76
Windows Media (asf),文件头:3026B2758E66CF11
MIDI (mid),文件头:4D546864
“.Replace(“文件头:“““);
string[] source2 = source.Split(new string[] { “\r\n“ “\n“ }StringSplitOptions.RemoveEmptyEntries);
foreach (string ss in source2)
{
string[] temp = ss.Split(‘,‘);
dict.Add(temp[1].Trim() temp[0].Trim() );
}
}
static string Hec16FormFile(string path)
{
FileStream fs = File.Open(pathFileMode.Open);
byte[] b = new byte[15];
fs.Read(b 0 15);
fs.Close();
string str = string.Empty;
foreach (byte myb in b)
{
string abc= Convert.ToString(myb16);
if (abc.Length == 1) abc = “0“ + abc;
str += abc;
}
return str.ToUpper();
}
static string check(string str)
{
for (int i = 15; i > 0; i--)
{
string temp = str.Substring(0 i);
KeyValuePair dd = dict.FirstOrDefault>(ele => ele.Key == temp);
if (dd.Value != null) return dd.Value;
}
return “can not find it“;
}
static void Main(string[] args)
{
//png bmp jpg tif doc mdb zip rar wav avi rm 通过测试
addDictionary();
while (true)
{
Console.WriteLine(“请输入文件路径:“);
string
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3563 2009-08-12 21:22 Program.cs
----------- --------- ---------- ----- ----
3563 1
- 上一篇:载波恢复 载波恢复 载波恢复
- 下一篇:WM算法C
评论
共有 条评论