控制台简易程序启动器代码

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

上一篇:frp内网穿透配置教程(一)— http内网穿透


下一篇:【转载】shell脚本读取ini配置文件的部分值