比如一个窗体要打开一个文本文档,那么可以用命令 xxx.exe kkk.txt,(本身这个应用程序不是console)

解决方案 »

  1.   

    [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(args[0]));//打开窗体时,传递要打开的文件
        }private string FileName="";//打开的文件名称
    public Form1(string filename)
    {
        InitializeComponent();
        FileName = filename;
    }private void Form1_Load(object sender, EventArgs e)
    {
        try
        {
            if (FileName != "")
                this.richTextBox1.LoadFile(FileName, RichTextBoxStreamType.PlainText);
        }
        catch (Exception Mye)
        {
            MessageBox.Show(this, Mye.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
    提供各种各样的C#例子,详见:http://www.psec.net.cn