控制台简易程序启动器代码
作者:互联网
using System;
using System.IO;//引入IO
using System.Text;
using System.Diagnostics;
namespace APPLauncher
{
class Program
{
public static void Main(string[] args)
{
try
{
//读取ini文件
byte[] b = new byte[1024 * 1024];
FileStream fileRead = new FileStream("Options.ini", FileMode.OpenOrCreate, FileAccess.Read);
int r = fileRead.Read(b, 0, b.Length);
string contents = Encoding.Default.GetString(b, 0, r);
//打开程序
Process process = new Process();//声明一个进程类对象
process.StartInfo.FileName =@contents;
process.Start();
}
catch
{
Console.WriteLine("-----------路径出错,未能启动应用程序-----------\n\n请在创建的[Options.ini]文件中输入应用相对路径,例如:\n\n根目录:\n ..\\test.txt \n上级目录:\n..\\..\\test.txt\n");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
}
标签:启动器,..,System,Console,ini,new,using,控制台,简易程序 来源: https://www.cnblogs.com/mane/p/15417645.html