System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "mspaint";
            p.Start();
            p.WaitForExit();
            MessageBox.Show("");

解决方案 »

  1.   

    namespace FileSystemWatcherExample
    {
        public partial class Form1 : Form
        {
            
            public Form1()
            {
                 InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                           // Create a new FileSystemWatcher and set its properties. 
                FileSystemWatcher watcher = new FileSystemWatcher();
                watcher.Path = "E:\\Project\\C#组件熟悉\\窗体控件\\FileSystemWatcherExample";
               
                /* Watch for changes in LastAccess and LastWrite times, and 
                           the renaming of files or directories. */            watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
              | NotifyFilters.FileName | NotifyFilters.DirectoryName;
                // Only watch text files. 
                watcher.Filter = "test.txt";            // Add event handlers. 
                watcher.Changed += new FileSystemEventHandler(OnChanged);
                watcher.Created += new FileSystemEventHandler(OnChanged);
                watcher.Deleted += new FileSystemEventHandler(OnChanged);
                watcher.Renamed += new RenamedEventHandler(OnRenamed);
                // Begin watching. 
                watcher.EnableRaisingEvents = true;
                // Wait for the user to quit the program.        }
            // Define the event handlers.
            private static void OnChanged(object source, FileSystemEventArgs e)
            {
                // Specify what is done when a file is changed, created, or deleted.
                MessageBox.Show("File: " + e.FullPath + " " + e.ChangeType);
            }        private static void OnRenamed(object source, RenamedEventArgs e)
            {
                // Specify what is done when a file is renamed.
           
                MessageBox.Show("File:" + e.OldFullPath + "renamed to" + e.FullPath);
            }    }
    }