我现在有了所有的 exe 文件,但问题是 xx 它给了我所有的 EXE,现在我必须在运行所需应用程序的可执行文件和所有垃圾可执行文件之间进行过滤。就像在 Internet Explorer 文件夹中一样,我有:
C:\Program Files\Internet Explorer\ieinstal.exe
C:\Program Files\Internet Explorer\ielowutil.exe
C:\Program Files\Internet Explorer\iexplorer.exe
但我只想要iexplorer.exe
文件,对我来说,其他所有文件都是垃圾。有没有办法在这些之间进行过滤?
List<string> path = new List<string>();
List<string> realPaths = new List<string>();
try
{
path.AddRange(Directory.GetFiles(@"C:\Program Files\", "*.exe", SearchOption.AllDirectories));
path.AddRange(Directory.GetFiles(@"C:\Program Files (x86)\", "*.exe", SearchOption.AllDirectories));
foreach (string item in path)
{
string[] parse = item.Split('\\');
if (parse.Contains("Common Files")
|| parse.Contains("IIS") || parse.Contains("Microsoft Help Viewer")
|| parse.Contains("Microsoft SQL Server") || parse.Contains("Microsoft SQL Server Compact Edition")
|| parse.Contains("Microsoft Sync Framework") || parse.Contains("Microsoft Synchronization Services")
|| parse.Contains("Microsoft Visual Studio 9.0") || parse.Contains("Microsoft.NET") || parse.Contains("MSBuild")
|| parse.Contains("Reference Assemblies") || parse.Contains("Windows Defender") || parse.Contains("Windows NT")
|| parse.Contains("HTML Help Workshop") || parse.Contains("Microsoft Analysis Services") || parse.Contains("Microsoft ASP.NET")
|| parse.Contains("Microsoft F#") || parse.Contains("Microsoft Games for Windows - LIVE") || parse.Contains("Microsoft SDKs")
|| parse.Contains("Microsoft Silverlight") || parse.Contains("Microsoft Visual Studio 8") || parse.Contains("Microsoft XNA")
|| parse.Contains("Mozilla Maintenance Service"))
{
continue;
}
else
{
realPaths.Add(item);
}
}
foreach (string item in realPaths)
{
Console.WriteLine(item + "\n");
}
}