getSteam

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.Management;
using System.IO;
using System.Diagnostics;

 

 

 


//获取steam的路径
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;
}
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;


}
string isExists(string d)
{
string steam = d + "\\steam".ToLower();

if (Directory.Exists(steam))
{
return steam;
}
return null;
}

posted @ 2018-03-19 12:49  bingxingc  阅读(215)  评论(0编辑  收藏  举报