Question uploading things..

LeonLanford

Active member
Joined
Dec 2, 2008
Messages
28
Programming Experience
Beginner
Hi.. I'm new here.. :D I'm using visual studio 2005
I just learnt vb.net not too long ago
I just made application to upload file to website but I have problems

1. How to make progress bar while uploading? I can make progress bar working by pressing a button, but don't know how to do it with uploading..
2. How to cancel the upload while uploading? Not closing the application I mean but pressing cancel button

the code is like this

VB.NET:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            My.Computer.Network.UploadFile("C:\ongoing.txt", "http://localhost/tes/uplot.php")
            MessageBox.Show("File uploaded.", "Upload Success")
        Catch ex As Exception
            MessageBox.Show("Access failed" & vbCrLf & ex.Message)
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Interval = 1
        Timer1.Enabled = True
        ProgressBar1.Value = 0
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If ProgressBar1.Value < 100 Then
            ProgressBar1.Value += 1
            Label1.Text = ProgressBar1.Value & " %"
            'Me.Label1.BackColor = System.Drawing.Color.Transparent

        Else
            Timer1.Enabled = False
        End If
    End Sub


End Class

thanks.. hope you can help me :D
 
Last edited by a moderator:
Use one of the other UploadFile methods where you can specify more parameters, one of them is the showUI Boolean value which make it display progress and allow user to cancel. You can also tell it what to do if users cancels, ie do nothing or throw an exception. The user and pass parameters you can set to empty string, which is also default values for the UploadFile overload you're using now.

Your other questions not related to this topic were split to other threads, see your thread list (from your forum page) Find all threads started by LeonLanford. Post different topics in separate threads in relevant forums.
.
 
Use one of the other UploadFile methods where you can specify more parameters, one of them is the showUI Boolean value which make it display progress and allow user to cancel. You can also tell it what to do if users cancels, ie do nothing or throw an exception. The user and pass parameters you can set to empty string, which is also default values for the UploadFile overload you're using now.

Your other questions not related to this topic were split to other threads, Visual Basic .NET Forums - Search Results
. Post different topics in relevant forums.

Sorry.. I don't understand.. Can you give example?
and sorry for irrelevant topic, I thought it can be merged into one about uploading..

thanks..
 
No, not with this method. You can call this method once for each file you want to upload in button click (via threading).
 
Back
Top