Foxtable(狐表)用户栏目专家坐堂 → 如何为远程文件增加上传下载进度条?


  共有1921人关注过本帖树形打印复制链接

主题:如何为远程文件增加上传下载进度条?

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/27 14:29:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/27 16:52:00 [显示全部帖子]

参考代码

 


Dim ofd As OpenFileDialog = New OpenFileDialog()
Dim res As DialogResult = ofd.ShowDialog()

If res = DialogResult.OK Then
   
    If Not String.IsNullOrEmpty(ofd.FileName) Then
        Dim streamRead As io.FileStream = New io.FileStream(ofd.FileName, io.FileMode.Open)
        Dim data As Byte() = New Byte(1048575) {}
        Dim length As Integer = 0
        Dim sfd As SaveFileDialog = New SaveFileDialog()
        Dim sres As DialogResult = sfd.ShowDialog()
       
        If sres = DialogResult.OK Then
           
            If Not String.IsNullOrEmpty(ofd.FileName) Then
                Dim streamWrite As io.FileStream = New io.FileStream(sfd.FileName, io.FileMode.Create)
                StatusBar.ProgressBar.Visible = True
                StatusBar.ProgressBar.Maximum = streamRead.length
                StatusBar.ProgressBar.Minimum = 1
                application.doevents
                Do
                    length = streamRead.Read(data, 0, data.Length)
                    StatusBar.ProgressBar.value += length
                    application.doevents
                    'For i As Integer = 0 To length - 1
                    '    data(i) = CByte((255 - data(i)))
                    'Next
                   
                    streamWrite.Write(data, 0, length)
                Loop While length = data.Length
streamWrite.close
            End If
        End If
    End If
End If


 回到顶部