0

Dear Friends i want to add a progrress bar in this uploader please help me ...

Imports System.IO
Imports System.Net

Public Class Form1

    Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.FtpWebRequest.Create("ftp://ftp.uibonline.com/uibsat/saleem.jpg"), System.Net.FtpWebRequest)
        request.Credentials = New System.Net.NetworkCredential("ksauib@uibonline.com", "123456")
        request.Method = System.Net.WebRequestMethods.Ftp.UploadFile


        Dim file() As Byte = IO.File.ReadAllBytes("C:\saleem.jpg")



        Dim strs As IO.Stream = request.GetRequestStream()
        strs.Write(file, 0, file.Length)
        MsgBox("File Uploaded", MsgBoxStyle.Information)

        strs.Close()
        strs.Dispose()
    End Sub

End Class
2
Contributors
1
Reply
12
Views
4 Years
Discussion Span
Last Post by Reverend Jim
0

As far as I know you cannot add a progress bar because the upload is being done in a single statement and there is no way to determine how much of the file has been uploaded at any given time. However, if you broke the upload into chunks and wrote the chunks in a loop you could update a progress bar. In one-byte chunks it would be

for each b as byte in file
    write the next byte
    update the progress bar
next

close the stream

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.