我想实现这样的功能:按下按钮,打开一个记事本,并显示“Hello!world”。而并不是打开一个有“Hello!world”内容的文本文件。
请问如何实现?多谢!

解决方案 »

  1.   


            System.Diagnostics.Process.Start("notepad","对记事本如何传参目前还不了解");
      

  2.   

    StreamWriter sw = File.AppendText("d:\\myText.txt"); 
    sw.WriteLine("Hello!world"); 
    sw.Flush(); 
    sw.Close(); 
    System.Diagnostics.Process txt = System.Diagnostics.Process.Start ( @"notepad.exe", @"d:\text_test.txt" );

    System.Diagnostics.Process txt = System.Diagnostics.Process.Start ( @"notepad.exe", @"d:\text_test.txt" );
    txt.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
    txt.WaitForInputIdle ( 1000 );
    if ( txt.Responding )
    {
    SendKeys.SendWait ( "Hello!world\r\n" );    
    SendKeys.SendWait ( "{Enter}{Enter}" );    
    SendKeys.SendWait ( "文档创建时间:" );
    SendKeys.SendWait ( "{F5}" );          
    SendKeys.SendWait ("{Enter}");       
    SendKeys.SendWait ( "^s" );       
    SendKeys.SendWait ( "%{F4}" );     
    MessageBox.Show ("文件已经保存成功!");
    }
    }