我目前正在为FiveM服务器创建一个自定义启动器。如果Process.Start
中存在FiveM文件夹,我想运行\AppData\Local
。
我想这样做,如果文件夹存在,因此,如果安装了fivem,它会启动软件,否则它会打开一个错误消息
下面是我的代码:
private void Button1_Click(object sender, EventArgs e)
{
Environment.GetEnvironmentVariable("LocalAppData");
if (!Directory.Exists("//FiveM"))
{
Process.Start("fivem://connect/144.217.11.186:30120");
MessageBox.Show("Veuillez patienter quelques secondes");
}
else
{
Hide();
error error = new error();
error.Show();
}
}
发布于 2019-06-21 01:55:26
获取特殊文件夹,将路径添加到其中(使用methods on System.IO.Path,而不是通过连接字符串),然后检查该目录是否存在:
string folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
string path = System.IO.Path.Combine(folder, "fivem");
if (Directory.Exists(path)) { ... }
发布于 2019-06-20 09:22:52
使用Directory.Exists
检查文件夹是否存在。
https://stackoverflow.com/questions/56659322
复制相似问题