控制台简易程序启动器代码
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【根目录下date文件夹下test.exe】\n .\\Data\\test.exe 或 Data\\test.txt \n\n【上级目录下date文件夹下test.exe】\n..\\Data\\test.exe \n\n【上两级目录下date文件夹下test.exe】\n..\\..\\Data\\test.exe\n");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
}