我希望在此过程中显示进度

时间:2017-12-01 07:40:58

标签: label progress

我希望在此过程中显示进度。但程序挂起,进度没有显示,直到进程结束。如何显示标签中的每个项目。 (每个文件操作需要很长时间(硬作业))    我正在使用visual studio 2008. VB.net或C#代码

  Dim files() As String = IO.Directory.GetFiles("*.ggpf")

    For Each filename As String In files
        Label1.Text = filename


        do 
        ......
        ...... Some write operations with file goes here 

        loop 




    Next

1 个答案:

答案 0 :(得分:0)

使用进度条工具,这些是基本属性:

ProgressBar1.Minimum = 0
ProgressBar1.Maximum = FileSize
ProgressBar1.Value = BytesSent

如果要将进度传递给对话框或标签:

Label1.Text = String.Format("{0}%", ((ProgressBar1.Value / ProgressBar1.Maximum) * 100).ToString("F2"))