吃鸡启动器
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Management;
using System.Windows.Forms;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string sSteam = getSteam() + "\\Steam.exe";
try
{
Process.Start(sSteam);
}
catch
{
MessageBox.Show("没有找到Steam.exe的位置");
}
}
//获取steam的路径
static string getSteam()
{
string sSteamDir = "";
//获取本地磁盘
DriveInfo[] aDr = DriveInfo.GetDrives();
foreach (DriveInfo dd in aDr)
{
if (dd.DriveType == DriveType.Fixed)
{
sSteamDir = isSteam(dd.ToString().ToLower());
if (sSteamDir != null)
{
return sSteamDir;
}
}
}
return null;
}
static string isSteam(string sDir)
{
string steam = "";
DirectoryInfo dDir = new DirectoryInfo(sDir);
if ((steam = isExists(sDir)) == null)
{
foreach (DirectoryInfo d in dDir.GetDirectories())
{
if ((steam = isExists(sDir + d.ToString())) != null)
{
return steam;
}
}
}
return null;
}
static string isExists(string d)
{
string steam = d + "\\steam".ToLower();
if (Directory.Exists(steam))
{
if (Directory.EnumerateDirectories(steam, "Steam.exe", SearchOption.AllDirectories).Any()==false)
return steam;
}
return null;
}
}
}