目前我有以下功能:
Private Function uploadFile(ByVal fileName As String)
Dim data() As Byte = IO.File.ReadAllBytes(fileName)
Dim base64String = System.Convert.ToBase64String(data)
Dim uploadURL As String = "http://192.168.0.7/upload.php"
Try
Using client As New Net.WebClient
Dim reqParm As New Specialized.NameValueCollection
reqParm.Add("body", base64String)
Dim responsebytes = client.UploadValues(uploadURL, "POST", reqParm)
Dim responsebody = (New Text.UTF8Encoding).GetString(responsebytes)
End Using
Catch ex As System.Net.WebException
MsgBox(ex.Message)
Finally
'
End Try
End Function
这会将 http 请求中的文件内容作为 base64 编码字符串发送。我想添加一个进度条,以便监控进度。使用 Java,我可以通过增加一个字节发送计数器来实现这一点,因为我一次向请求的输出流添加一个字节。我是否有与 VB.net 相同的选项,或者可能有其他选项?感谢您的任何想法