代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void btnPath_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
txtPath.Text
= folderBrowserDialog1.SelectedPath;
string P = lblPath.Text;
IsTrue(txtPath.Text);

}
}

private void IsTrue(string p)
{
DirectoryInfo dinfo
= new DirectoryInfo(p);
FileSystemInfo[] fsinfos
= dinfo.GetFileSystemInfos();
foreach (FileSystemInfo fsinfo in fsinfos)
{
if (fsinfo is DirectoryInfo)
{
IsTrue(fsinfo.FullName);
}
else
{
if (IsName(fsinfo.FullName))
{
FileInfo finfo
= new FileInfo(fsinfo.Name);
listView1.Items.Add(fsinfo.Name);
listView1.Items[listView1.Items.Count
- 1].SubItems.Add(System.IO.Path.GetExtension(finfo.FullName));
listView1.Items[listView1.Items.Count
- 1].SubItems.Add(finfo.FullName);
listView1.Items[listView1.Items.Count
- 1].SubItems.Add(finfo.GetType().ToString());
}

}
}
}
private bool IsName(string path)
{
bool xx = false;
System.IO.FileStream fs
= new System.IO.FileStream(path, 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();
//txt.Text += bx+"||||";
if (System.IO.Path.GetExtension(path).ToLower() == ".exe")//7790:exe,8297:rar,8075:pk
{
if (bx == "7790")
{ xx
= true; }
}
//Console.WriteLine(bx);

return xx;

}

}
}