troubleshooting Question

how do I display progress uploading file?

Avatar of JAPorter1983
JAPorter1983 asked on
Visual Basic ClassicWeb Development Software.NET Programming
2 Comments1 Solution1105 ViewsLast Modified:
Hello,
I am trying to display a progress bar to show the progress of an image upload using the httpwebrequest class.  The code displayed shows the function I use to upload the image, I can't figure out how to get the progress to display.  I think it may require something with the async functions but I am not sure.  Any help would be great.

Thanks
Function TUpload(ByVal _fileInfo As FileInfo)
        _startTime = DateTime.Now
        _mfileInfo = _fileInfo
        _totalChunks = _mfileInfo.Length / 1024
        Dim request As HttpWebRequest = DirectCast(WebRequest.Create(BuildURL(_mfileInfo)), HttpWebRequest)
        request.Method = WebRequestMethods.Http.Post
        request.AllowWriteStreamBuffering = False
        request.Headers.Add("X-Zenfolio-Token", _client.Token)
        request.ContentType = MimeType(_fileInfo)
        request.UserAgent = "Express Send :: Text Connects Software"
 
        Dim sourceStream
 
        Dim fileContents As Byte()
        sourceStream = New FileStream(_mfileInfo.FullName, FileMode.Open)
 
        Using sourceStream
            fileContents = New Byte(sourceStream.Length - 1) {}
            sourceStream.Read(fileContents, 0, fileContents.Length)
        End Using
 
        sourceStream.Close()
        request.ContentLength = fileContents.Length
 
        Dim requestStream As Stream = request.GetRequestStream()
        requestStream.Write(fileContents, 0, fileContents.Length)
 
        requestStream.Close()
        Return "done"
    End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros