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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.