有没有好点的地方!!要学习一下!!

解决方案 »

  1.   

    private void CopyWithProgress(string[] filenames)
    {
        // 显示.
        pBar1.Visible = true;
        // 进度条的最小值为1,默认从1开始增加,数字增加,进度条跟据数据递增.
        pBar1.Minimum = 1;
        // 进度条的最大值,进度条跑满时的数字.
        pBar1.Maximum = filenames.Length;
        // 进度条初始值,默认从最小值开始.
        pBar1.Value = 1;
        // 进度条每次增加的值,默认为1.
        pBar1.Step = 1;
        
        // 最关键的在这里.
        for (int x = 1; x <= filenames.Length; x++)
        {
            // Copy the file and increment the ProgressBar if successful.
            if(CopyFile(filenames[x-1]) == true)
            {
                // 跟据循环,进度条改变进度.
                pBar1.PerformStep();
            }
        }
    }
      

  2.   

    http://community.csdn.net/Expert/topic/4647/4647922.xml?temp=.3597834
      

  3.   

    帮助中提供的例子:using System;
    using System.Diagnostics;
    using System.ComponentModel;namespace MyProcessSample
    {
        /// <summary>
        /// Shell for the sample.
        /// </summary>
        public class MyProcess
        {
            // These are the Win32 error code for file not found or access denied.
            const int ERROR_FILE_NOT_FOUND =2;
            const int ERROR_ACCESS_DENIED = 5;        /// <summary>
            /// Prints a file with a .doc extension.
            /// </summary>
            public void PrintDoc()
            {
                Process myProcess = new Process();
                
                try
                {
                    // Get the path that stores user documents.
                    string myDocumentsPath = 
                        Environment.GetFolderPath(Environment.SpecialFolder.Personal);                myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc"; 
                    myProcess.StartInfo.Verb = "Print";
                    myProcess.StartInfo.CreateNoWindow = true;
                    myProcess.Start();
                }
                catch (Win32Exception e)
                {
                    if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
                    {
                        Console.WriteLine(e.Message + ". Check the path.");
                    }                 else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
                    {
                        // Note that if your word processor might generate exceptions
                        // such as this, which are handled first.
                        Console.WriteLine(e.Message + 
                            ". You do not have permission to print this file.");
                    }
                }
            }
            public static void Main()
            {
                MyProcess myProcess = new MyProcess();
                myProcess.PrintDoc();
            }
        }
    }
      

  4.   

    Process使你的应用程序中可以启动或停止本地或远程的进程。简单说,就是使你可以在不退出一个程序的情况下,运行另一个可执行文件。