Process.Start("Notepad");
先创建一个记事本,然后往里面添加文字,不是写好路径创建,
而是一开始就用 Process.Start("Notepad"); 创建一个记事本(不指定路径的),
往里面添加文字之后再操作保存什么的。
FileStream fs = new FileStream(@"D:\example.txt", FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.BaseStream.Seek(0, SeekOrigin.Begin);
            sw.WriteLine("hi");
            sw.Close();
不是要这个,不知道我说没说明白

解决方案 »

  1.   

    先建立一个不指定路径的记事本,(就是一开始就用 Process.Start("Notepad");建立一个空白的记事本 )
    然后往里面添加任意内容,然后在保存的时候指定路径
      

  2.   

    看明白了,LZ想在调用Notepad记事本程序后,继续对该记事本进行操作,如写入文本信息,最后保存记事本中的文本内容。
      

  3.   

                Process.Start("notepad", "test.txt");
      

  4.   

    1)FindWindow  找到记事本窗口并找到它的Edit子窗口
    2)然后用SetWindowText
      

  5.   

    用Process.Start("notepad", "test.txt");可以创建但开始时会弹出创建的提示对话框。
    Process.Start(string,string)的一个实例
    using System;
    using System.Diagnostics;
    using System.ComponentModel;namespace MyProcessSample
    {
    /// <summary>
    /// Shell for the sample.
    /// </summary>
    class MyProcess
    {
       
    /// <summary>
    /// Opens the Internet Explorer application.
    /// </summary>
    void OpenApplication(string myFavoritesPath)
    {
    // Start Internet Explorer. Defaults to the home page.
    Process.Start("IExplore.exe");
        
        // Display the contents of the favorites folder in the browser.
        Process.Start(myFavoritesPath);
     
    }

    /// <summary>
    /// Opens urls and .html documents using Internet Explorer.
    /// </summary>
    void OpenWithArguments()
    {
    // url's are not considered documents. They can only be opened
    // by passing them as arguments.
    Process.Start("IExplore.exe", "www.northwindtraders.com");

    // Start a Web page using a browser associated with .html and .asp files.
    Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
    Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
    }

    /// <summary>
    /// Uses the ProcessStartInfo class to start new processes, both in a minimized 
    /// mode.
    /// </summary>
    void OpenWithStartInfo()
    {

    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;

    Process.Start(startInfo);

    startInfo.Arguments = "www.northwindtraders.com";

    Process.Start(startInfo);

    } static void Main()
    {
                 // Get the path that stores favorite links.
                 string myFavoritesPath = 
                     Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
                    
                 MyProcess myProcess = new MyProcess();
             
    myProcess.OpenApplication(myFavoritesPath);
    myProcess.OpenWithArguments();
    myProcess.OpenWithStartInfo();        }
    }
    }