我写了一个程序,想把一个txt文件拖拽到图标上,打开它。而非打开了程序拖动到窗口打开,请问有什么办法?

解决方案 »

  1.   

    这个很简单呀,直接上代码Program.cspublic static string[] MyArgs; 
            [STAThread]
            static void Main(string[] args)
            {
                MyArgs = args;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
    Form1private void Form1_Load(object sender, EventArgs e)
            {
                using (StreamReader sr = new StreamReader(Program.MyArgs[0]))
                {
                    richTextBox1.Text = sr.ReadToEnd();
                }
            }