以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何为远程文件增加上传下载进度条?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=119556)

--  作者:cq66667372
--  发布时间:2018/5/27 14:04:00
--  如何为远程文件增加上传下载进度条?
我编制了一个办公软件,设置了局域网内的远程文件,在上传较大的文件时等待时间长,不知道上传的进度,想设置一个进度条,不知如何设置,请老师指教!
--  作者:有点甜
--  发布时间:2018/5/27 14:29:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=78301&skin=0

 


--  作者:cq66667372
--  发布时间:2018/5/27 15:14:00
--  可能我没有表达清楚
我想要的不是用FTP上传文件,而是用多文件的本地局域网的共享文件夹存文件,感觉比FTP更方便,但没有上传和下载的进度条,想做一个。
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间: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