博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
吃鸡启动器
阅读量:7249 次
发布时间:2019-06-29

本文共 1279 字,大约阅读时间需要 4 分钟。

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;
}

}
}

 

转载于:https://www.cnblogs.com/bingxing/p/8612838.html

你可能感兴趣的文章
【Ubuntu17.10】【Python】菜鸟新建文件夹、给予777权限、新建一个简单的python脚本测试...
查看>>
2018 浅谈前端面试那些事
查看>>
flutter实战3:解析HTTP请求数据和制作新闻分类列表
查看>>
react onCompositionStart/Update/onCompositionStartEnd 触发时机
查看>>
一个强大的批处理文件
查看>>
基于 Swoole 的微信扫码登录
查看>>
Largest Rectangle in Histogram
查看>>
聊聊pg jdbc的queryTimeout及next方法
查看>>
golang 依赖管理
查看>>
Java常用工具类整理
查看>>
FED之必备技能
查看>>
高性能磁盘 I/O 开发学习笔记 -- 硬件原理篇
查看>>
一个还算优雅的 react 图片组件
查看>>
JSON应知应会
查看>>
一个PHP文件搞定支付宝系列之手机网站支付(兼容微信浏览器)
查看>>
设计模式之代理模式
查看>>
客服系统从Require.js到Webpack
查看>>
React 16 中的异常处理
查看>>
独家解析Javascript原型继承
查看>>
springboot集成mqtt
查看>>