现在正在做一个备份程序,可以支持磁盘、mo、磁带、网络等备份方式。现在想在备份的时候显示进度。应该如何实现?
能不能给个思路,最好还是代码段?
有没有集成windows自带的拷贝进度条到我们的 系统里面来 的 可能性?

解决方案 »

  1.   

    private delegate void DelegateSetStatusBar(int rate);
    public void SetNewsStatusBar(int rate)
    {
    Invoke(new DelegateSetStatusBar(InternalSetStatusBar), new object[]{rate});
    }private void InternalSetStatusBar(int rate)
    {
    int value = rate;
    value = Math.Max(value, progressBar.Minimum);
    value = Math.Min(value, progressBar.Maximum);
    progressBar.Value = value;
    }
      

  2.   

    // Display the ProgressBar control.
        pBar1.Visible = true;
        // Set Minimum to 1 to represent the first file being copied.
        pBar1.Minimum = 1;
        // Set Maximum to the total number of files to copy.
        pBar1.Maximum = filenames.Length;
        // Set the initial value of the ProgressBar.
        pBar1.Value = 1;
        // Set the Step property to a value of 1 to represent each file being copied.
        pBar1.Step = 1;
        
        // Loop through all files to copy.
        for (int x = 1; x <= filenames.Length; x++)
        {
            // Copy the file and increment the ProgressBar if successful.
            if(CopyFile(filenames[x-1]) == true)
            {
                // Perform the increment on the ProgressBar.
                pBar1.PerformStep();
            }
        }
    msdn中的,具体可以去看看