Results 1 to 23 of 23

Thread: wait

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Cool wait

    hi there.
    i have a problem

    in VB i try to make a multi file downloader. but until now it downloads
    all files at once to 1 file... (
    i want my code to download all files to 1 FOLDER and the code must wait before starting another download

    here is my code
    VB.net Code:
    1. Try
    2.             httpclient.DownloadFileAsync(New Uri(sourceURL), (filedir))
    3.  
    4.  
    5.  
    6.         Catch ex As Exception
    7.             MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    8.  
    9.  
    10.         End Try
    11.         'effe wachten...
    12.  
    13.         'klaar ga verder dan..
    14.  
    15.         If CheckBoxX1.Checked = True Then
    16.             Try
    17.                 httpclient.DownloadFileAsync(New Uri(sourceURL2), (filedir))
    18.  
    19.  
    20.  
    21.             Catch ex As Exception
    22.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    23.  
    24.  
    25.             End Try
    26.         End If
    27.         'effe wachten...
    28.         'klaar ga verder dan..
    29.         If CheckBoxX2.Checked = True Then
    30.             Try
    31.                 httpclient.DownloadFileAsync(New Uri(sourceURL3), (filedir))
    32.  
    33.  
    34.  
    35.             Catch ex As Exception
    36.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    37.  
    38.  
    39.             End Try
    40.         End If
    41.         'effe wachten...
    42.         'klaar ga verder dan..
    43.         If CheckBoxX3.Checked = True Then
    44.             Try
    45.                 httpclient.DownloadFileAsync(New Uri(sourceURL4), (filedir))
    46.  
    47.  
    48.  
    49.             Catch ex As Exception
    50.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    51.  
    52.  
    53.             End Try
    54.         End If
    55.         'effe wachten...
    56.         'klaar ga verder dan..
    57.         If CheckBoxX4.Checked = True Then
    58.             Try
    59.                 httpclient.DownloadFileAsync(New Uri(sourceURL5), (filedir))
    60.  
    61.  
    62.  
    63.             Catch ex As Exception
    64.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    65.  
    66.  
    67.             End Try
    68.         End If
    69.         'effe wachten...
    70.         'klaar ga verder dan..
    71.         If CheckBoxX5.Checked = True Then
    72.             Try
    73.                 httpclient.DownloadFileAsync(New Uri(sourceURL6), (filedir))
    74.  
    75.  
    76.  
    77.             Catch ex As Exception
    78.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    79.  
    80.             End Try
    81.         End If
    82.         'effe wachten...
    83.         'klaar ga verder dan..
    84.         If CheckBoxX6.Checked = True Then
    85.             Try
    86.                 httpclient.DownloadFileAsync(New Uri(sourceURL7), (filedir))
    87.  
    88.  
    89.  
    90.             Catch ex As Exception
    91.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    92.  
    93.             End Try
    94.         End If
    95.         'effe wachten...
    96.         'klaar ga verder dan..
    97.         If CheckBoxX7.Checked = True Then
    98.             Try
    99.                 httpclient.DownloadFileAsync(New Uri(sourceURL8), (filedir))
    100.  
    101.  
    102.  
    103.             Catch ex As Exception
    104.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    105.  
    106.             End Try
    107.         End If
    108.         'effe wachten...
    109.         'klaar ga verder dan..
    110.         If CheckBoxX8.Checked = True Then
    111.             Try
    112.                 httpclient.DownloadFileAsync(New Uri(sourceURL9), (filedir))
    113.  
    114.  
    115.  
    116.             Catch ex As Exception
    117.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    118.  
    119.             End Try
    120.         End If
    121.         'effe wachten...
    122.         'klaar ga verder dan..
    123.         If CheckBoxX9.Checked = True Then
    124.             Try
    125.                 httpclient.DownloadFileAsync(New Uri(sourceURL10), (filedir))
    126.  
    127.  
    128.  
    129.             Catch ex As Exception
    130.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    131.  
    132.             End Try
    133.  
    134.         End If
    as u can see the sourceurl 1-10 has been programmed as textboxes (urls)
    filedir must become the directory that the files must be downloaded to.
    but imust type the name after it or it just doesnt start

    any way to let
    1. VB wait the code until download is completed then continue the code
    2. download all files to 1 DIrectory

    thanks

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: wait

    1. Since all the downloads is saved to the same (filedir) location, the later one will overwrite the previous one. You have to to provide a different file path for each download. You can have the same folder path but the file name has to be different for each download.
    Code:
    Dim downloadFolder as string = "put the full path to the folder you want to save here, for example C:\Downloads"
     httpclient.DownloadFileAsync(New Uri(sourceURL1), downloadFolder & "\file1.xzy")
     httpclient.DownloadFileAsync(New Uri(sourceURL2), downloadFolder & "\file2.xzy")
    ....
    If you want to wait for the 1st download to complete before start the 2nd download, don't call DownloadFileAsync. Just call DownloadFile method because this is a blocking method.
    Code:
    httpClient.DownloadFile(url1, path1)
    httpClient.DownloadFile(url2, path2)
    .......................
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    well now it does not work anymore
    i get this

    VB.net Code:
    1. System.Net.WebException was unhandled
    2.  
    3.   Message=Tijdens een WebClient-aanvraag is een uitzondering opgetreden.
    4.   Source=System
    5.   StackTrace:
    6.        bij System.Net.WebClient.DownloadFile(Uri address, String fileName)
    7.        bij System.Net.WebClient.DownloadFile(String address, String fileName)
    8.        bij MC_downloader.Form1.ButtonItem1_Click(Object sender, EventArgs e) in C:\Users\mc pc\documents\visual studio 2010\Projects\MC downloader\MC downloader\Form1.vb:regel 33
    9.        bij DevComponents.DotNetBar.BaseItem.RaiseClick(eEventSource source)
    10.        bij DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
    11.        bij DevComponents.DotNetBar.PopupItem.InternalMouseUp(MouseEventArgs objArg)
    12.        bij DevComponents.DotNetBar.ButtonItem.InternalMouseUp(MouseEventArgs objArg)
    13.        bij DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
    14.        bij DevComponents.DotNetBar.ItemContainer.InternalMouseUp(MouseEventArgs objArg)
    15.        bij DevComponents.DotNetBar.ItemControl.OnMouseUp(MouseEventArgs e)
    16.        bij DevComponents.DotNetBar.RibbonBar.OnMouseUp(MouseEventArgs e)
    17.        bij System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    18.        bij System.Windows.Forms.Control.WndProc(Message& m)
    19.        bij System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    20.        bij System.Windows.Forms.ContainerControl.WndProc(Message& m)
    21.        bij DevComponents.DotNetBar.ItemControl.WndProc(Message& m)
    22.        bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    23.        bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    24.        bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    25.        bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    26.        bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    27.        bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    28.        bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    29.        bij System.Windows.Forms.Application.Run(ApplicationContext context)
    30.        bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    31.        bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    32.        bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    33.        bij MC_downloader.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:regel 81
    34.        bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    35.        bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    36.        bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    37.        bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    38.        bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    39.        bij System.Threading.ThreadHelper.ThreadStart()
    40.   InnerException: System.ArgumentException
    41.        Message=Lege padnaam is niet geldig.
    42.        Source=mscorlib
    43.        StackTrace:
    44.             bij System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
    45.             bij System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
    46.             bij System.Net.WebClient.DownloadFile(Uri address, String fileName)
    47.        InnerException:

    this is my code now
    VB.net Code:
    1. httpclient.DownloadFile(sourceURL, filedir)
    2.  
    3.         If CheckBoxX1.Checked = True Then
    4.  
    5.             httpclient.DownloadFile(sourceURL2, filedir)
    6.             ProgressBarX2.Value = "100"
    7.         End If
    8.         'effe wachten...
    9.         'klaar ga verder dan..
    10.         If CheckBoxX2.Checked = True Then
    11.             httpclient.DownloadFile(sourceURL3, filedir)
    12.             ProgressBarX3.Value = "100"
    13.         End If
    14.         'effe wachten...
    15.         'klaar ga verder dan..
    16.         If CheckBoxX3.Checked = True Then
    17.             httpclient.DownloadFile(sourceURL4, filedir)
    18.             ProgressBarX4.Value = "100"
    19.         End If
    20.         'effe wachten...
    21.         'klaar ga verder dan..
    22.         If CheckBoxX4.Checked = True Then
    23.  
    24.             httpclient.DownloadFile(sourceURL5, filedir)
    25.             ProgressBarX5.Value = "100"
    26.         End If
    27.         'effe wachten...
    28.         'klaar ga verder dan..
    29.         If CheckBoxX5.Checked = True Then
    30.  
    31.             httpclient.DownloadFile(sourceURL6, filedir)
    32.             ProgressBarX6.Value = "100"
    33.         End If
    34.         'effe wachten...
    35.         'klaar ga verder dan..
    36.         If CheckBoxX6.Checked = True Then
    37.                 httpclient.DownloadFile(sourceURL7, filedir)
    38.                 ProgressBarX7.Value = "100"
    39.         End If
    40.         'effe wachten...
    41.         'klaar ga verder dan..
    42.         If CheckBoxX7.Checked = True Then
    43.  
    44.             httpclient.DownloadFile(sourceURL8, filedir)
    45.             ProgressBarX8.Value = "100"
    46.         End If
    47.         'effe wachten...
    48.         'klaar ga verder dan..
    49.         If CheckBoxX8.Checked = True Then
    50.  
    51.             httpclient.DownloadFile(sourceURL9, filedir)
    52.             ProgressBarX9.Value = "100"
    53.         End If
    54.         'effe wachten...
    55.         'klaar ga verder dan..
    56.         If CheckBoxX9.Checked = True Then
    57.  
    58.             httpclient.DownloadFile(sourceURL10, filedir)
    59.             ProgressBarX10.Value = "100"
    60.         End If

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: wait

    What is the error message? I can't read whatever language it is in the exception message you posted. Care to translate it to English?
    What is the value of sourceURL and filedir variables when the exception is thrown?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    the error is that During a WebClient request is an exception occurred
    url is a rar file on my webserver www.host-it.org/privatefile.rar
    path to file = D:\downloads

    i'm administrator on the pc.
    the language is dutch

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    no more responce? can anyone solve this

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: wait

    You need to be very specific about the error.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    well . my VB lang is dutch i alraidy given the error code and translation

    (the download doesnt even start i get directly a error :
    During a WebClient request is an exception occurred
    )
    nothing more nothing less.
    any fix for this?

  9. #9
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: wait

    Assuming the error occurs during the .DownloadFile wrap them in a Try-Catch block and trap the exceptions listed here

    http://msdn.microsoft.com/en-us/library/ms144194.aspx
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    now i dont get any error. but it doesnt start download. again
    my full code:
    VB.net Code:
    1. Private WithEvents httpclient As WebClient
    2.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    3.  
    4.     End Sub
    5.     Public Sub DownloadFile1( _
    6.  ByVal sourceURL As Uri, _
    7.  ByVal filedir As String _
    8. )
    9.     End Sub
    10.     Public Sub DownloadFile2( _
    11.  ByVal sourceURL2 As Uri, _
    12.  ByVal filedir As String _
    13. )
    14.     End Sub
    15.     Public Sub DownloadFile3( _
    16.  ByVal sourceURL3 As Uri, _
    17.  ByVal filedir As String _
    18. )
    19.     End Sub
    20.     Public Sub DownloadFile4( _
    21.  ByVal sourceURL4 As Uri, _
    22.  ByVal filedir As String _
    23. )
    24.     End Sub
    25.     Public Sub DownloadFile5( _
    26.  ByVal sourceURL5 As Uri, _
    27.  ByVal filedir As String _
    28. )
    29.     End Sub
    30.     Public Sub DownloadFile6( _
    31.  ByVal sourceURL6 As Uri, _
    32.  ByVal filedir As String _
    33. )
    34.     End Sub
    35.     Public Sub DownloadFile7( _
    36.  ByVal sourceURL7 As Uri, _
    37.  ByVal filedir As String _
    38. )
    39.     End Sub
    40.     Public Sub DownloadFile8( _
    41.  ByVal sourceURL8 As Uri, _
    42.  ByVal filedir As String _
    43. )
    44.     End Sub
    45.     Public Sub DownloadFile9( _
    46.  ByVal sourceURL9 As Uri, _
    47.  ByVal filedir As String _
    48. )
    49.     End Sub
    50.     Public Sub DownloadFile10( _
    51.  ByVal sourceURL10 As Uri, _
    52.  ByVal filedir As String _
    53. )
    54.     End Sub
    55.  
    56.  
    57.     Private Sub ButtonItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem1.Click
    58.  
    59.         httpclient = New WebClient
    60.         Dim sourceURL = TextBoxX2.Text
    61.         Dim sourceURL2 = TextBoxX3.Text
    62.         My.Resources.gear.Save(My.Computer.FileSystem.SpecialDirectories.Temp & "\tempicon.ico", Imaging.ImageFormat.Icon)
    63.         NotifyIcon1.Icon = My.Resources.gear1
    64.         Refresh()
    65.         NotifyIcon1.Text = "Downloading in progress - MC Downloader"
    66.         NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
    67.         NotifyIcon1.BalloonTipText = "Downloading files"
    68.         NotifyIcon1.BalloonTipTitle = "MC Downloader"
    69.         NotifyIcon1.ShowBalloonTip(10000)
    70.         Dim sourceURL3 = TextBoxX4.Text
    71.         Dim sourceURL4 = TextBoxX5.Text
    72.         Dim sourceURL5 = TextBoxX6.Text
    73.         Dim sourceURL6 = TextBoxX7.Text
    74.         Dim sourceURL7 = TextBoxX8.Text 'v
    75.         Dim sourceURL8 = TextBoxX9.Text
    76.         Dim sourceURL9 = TextBoxX10.Text
    77.         Dim sourceURL10 = TextBoxX11.Text
    78.         Dim filedir As String = TextBoxX1.Text
    79.         filedir = TextBoxX1.Text
    80.  
    81.         DownloadFile1(New Uri(sourceURL), filedir)
    82.  
    83.         If CheckBoxX1.Checked = True Then
    84.  
    85.             DownloadFile2(New Uri(sourceURL2), filedir)
    86.             ProgressBarX2.Value = "100"
    87.         End If
    88.         'effe wachten...
    89.         'klaar ga verder dan..
    90.         If CheckBoxX2.Checked = True Then
    91.             DownloadFile3(New Uri(sourceURL3), filedir)
    92.             ProgressBarX3.Value = "100"
    93.         End If
    94.         'effe wachten...
    95.         'klaar ga verder dan..
    96.         If CheckBoxX3.Checked = True Then
    97.             DownloadFile4(New Uri(sourceURL4), filedir)
    98.             ProgressBarX4.Value = "100"
    99.         End If
    100.         'effe wachten...
    101.         'klaar ga verder dan..
    102.         If CheckBoxX4.Checked = True Then
    103.  
    104.             DownloadFile5(New Uri(sourceURL5), filedir)
    105.             ProgressBarX5.Value = "100"
    106.         End If
    107.         'effe wachten...
    108.         'klaar ga verder dan..
    109.         If CheckBoxX5.Checked = True Then
    110.  
    111.             DownloadFile6(New Uri(sourceURL6), filedir)
    112.             ProgressBarX6.Value = "100"
    113.         End If
    114.         'effe wachten...
    115.         'klaar ga verder dan..
    116.         If CheckBoxX6.Checked = True Then
    117.             DownloadFile7(New Uri(sourceURL7), filedir)
    118.             ProgressBarX7.Value = "100"
    119.         End If
    120.         'effe wachten...
    121.         'klaar ga verder dan..
    122.         If CheckBoxX7.Checked = True Then
    123.  
    124.             DownloadFile8(New Uri(sourceURL8), filedir)
    125.             ProgressBarX8.Value = "100"
    126.         End If
    127.         'effe wachten...
    128.         'klaar ga verder dan..
    129.         If CheckBoxX8.Checked = True Then
    130.  
    131.             DownloadFile9(New Uri(sourceURL9), filedir)
    132.             ProgressBarX9.Value = "100"
    133.         End If
    134.         'effe wachten...
    135.         'klaar ga verder dan..
    136.         If CheckBoxX9.Checked = True Then
    137.  
    138.             DownloadFile10(New Uri(sourceURL10), filedir)
    139.             ProgressBarX10.Value = "100"
    140.         End If
    141.         If ProgressBarX1.Value > "99" Then
    142.             NotifyIcon1.Icon = My.Resources.tick1
    143.             NotifyIcon1.Text = "Done - MC Downloader"
    144.             NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
    145.             NotifyIcon1.BalloonTipText = "Downloading finished"
    146.             NotifyIcon1.BalloonTipTitle = "MC Downloader"
    147.             NotifyIcon1.ShowBalloonTip(10000)
    148.             ProgressBarX1.Refresh()
    149.         End If
    150.     End Sub

  11. #11
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: wait

    FTD-er?

    The Exception you gave earlier says that one of the path's is empty. Not sure though whether it's the URL or the filepath.
    What is the line at which the error occurs?
    Delete it. They just clutter threads anyway.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    i dont get a error now. it just doesnt start the download. so thats a problem...

    ps. DBP.er (ex FTDer)

  13. #13
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: wait

    I don't see the Try-Catch..
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    i did that see my code:
    VB.net Code:
    1. Private WithEvents httpclient As WebClient
    2.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    3.  
    4.     End Sub
    5.     Public Sub DownloadFile1( _
    6.  ByVal sourceURL As Uri, _
    7.  ByVal filedir As String _
    8. )
    9.     End Sub
    10.     Public Sub DownloadFile2( _
    11.  ByVal sourceURL2 As Uri, _
    12.  ByVal filedir As String _
    13. )
    14.     End Sub
    15.     Public Sub DownloadFile3( _
    16.  ByVal sourceURL3 As Uri, _
    17.  ByVal filedir As String _
    18. )
    19.     End Sub
    20.     Public Sub DownloadFile4( _
    21.  ByVal sourceURL4 As Uri, _
    22.  ByVal filedir As String _
    23. )
    24.     End Sub
    25.     Public Sub DownloadFile5( _
    26.  ByVal sourceURL5 As Uri, _
    27.  ByVal filedir As String _
    28. )
    29.     End Sub
    30.     Public Sub DownloadFile6( _
    31.  ByVal sourceURL6 As Uri, _
    32.  ByVal filedir As String _
    33. )
    34.     End Sub
    35.     Public Sub DownloadFile7( _
    36.  ByVal sourceURL7 As Uri, _
    37.  ByVal filedir As String _
    38. )
    39.     End Sub
    40.     Public Sub DownloadFile8( _
    41.  ByVal sourceURL8 As Uri, _
    42.  ByVal filedir As String _
    43. )
    44.     End Sub
    45.     Public Sub DownloadFile9( _
    46.  ByVal sourceURL9 As Uri, _
    47.  ByVal filedir As String _
    48. )
    49.     End Sub
    50.     Public Sub DownloadFile10( _
    51.  ByVal sourceURL10 As Uri, _
    52.  ByVal filedir As String _
    53. )
    54.     End Sub
    55.  
    56.  
    57.     Private Sub ButtonItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem1.Click
    58.  
    59.         httpclient = New WebClient
    60.         Dim sourceURL = TextBoxX2.Text
    61.         Dim sourceURL2 = TextBoxX3.Text
    62.         My.Resources.gear.Save(My.Computer.FileSystem.SpecialDirectories.Temp & "\tempicon.ico", Imaging.ImageFormat.Icon)
    63.         NotifyIcon1.Icon = My.Resources.gear1
    64.         Refresh()
    65.         NotifyIcon1.Text = "Downloading in progress - MC Downloader"
    66.         NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
    67.         NotifyIcon1.BalloonTipText = "Downloading files"
    68.         NotifyIcon1.BalloonTipTitle = "MC Downloader"
    69.         NotifyIcon1.ShowBalloonTip(10000)
    70.         Dim sourceURL3 = TextBoxX4.Text
    71.         Dim sourceURL4 = TextBoxX5.Text
    72.         Dim sourceURL5 = TextBoxX6.Text
    73.         Dim sourceURL6 = TextBoxX7.Text
    74.         Dim sourceURL7 = TextBoxX8.Text 'v
    75.         Dim sourceURL8 = TextBoxX9.Text
    76.         Dim sourceURL9 = TextBoxX10.Text
    77.         Dim sourceURL10 = TextBoxX11.Text
    78.         Dim filedir As String = TextBoxX1.Text
    79.         filedir = TextBoxX1.Text
    80.         Try
    81.             DownloadFile1(New Uri(sourceURL), filedir)
    82.         Catch ex As Exception
    83.             MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    84.  
    85.         End Try
    86.  
    87.         If CheckBoxX1.Checked = True Then
    88.             Try
    89.                 DownloadFile2(New Uri(sourceURL2), filedir)
    90.                 ProgressBarX2.Value = "100"
    91.             Catch ex As Exception
    92.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    93.  
    94.             End Try
    95.         End If
    96.         'effe wachten...
    97.         'klaar ga verder dan..
    98.         If CheckBoxX2.Checked = True Then
    99.             Try
    100.                 DownloadFile3(New Uri(sourceURL3), filedir)
    101.                 ProgressBarX3.Value = "100"
    102.             Catch ex As Exception
    103.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    104.  
    105.             End Try
    106.         End If
    107.         'effe wachten...
    108.         'klaar ga verder dan..
    109.         If CheckBoxX3.Checked = True Then
    110.             Try
    111.                 DownloadFile4(New Uri(sourceURL4), filedir)
    112.                 ProgressBarX4.Value = "100"
    113.             Catch ex As Exception
    114.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    115.  
    116.             End Try
    117.         End If
    118.         'effe wachten...
    119.         'klaar ga verder dan..
    120.         If CheckBoxX4.Checked = True Then
    121.             Try
    122.                 DownloadFile5(New Uri(sourceURL5), filedir)
    123.                 ProgressBarX5.Value = "100"
    124.             Catch ex As Exception
    125.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    126.  
    127.             End Try
    128.         End If
    129.         'effe wachten...
    130.         'klaar ga verder dan..
    131.         If CheckBoxX5.Checked = True Then
    132.             Try
    133.                 DownloadFile6(New Uri(sourceURL6), filedir)
    134.                 ProgressBarX6.Value = "100"
    135.             Catch ex As Exception
    136.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    137.  
    138.             End Try
    139.         End If
    140.         'effe wachten...
    141.         'klaar ga verder dan..
    142.         If CheckBoxX6.Checked = True Then
    143.             Try
    144.                 DownloadFile7(New Uri(sourceURL7), filedir)
    145.                 ProgressBarX7.Value = "100"
    146.             Catch ex As Exception
    147.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    148.  
    149.             End Try
    150.         End If
    151.         'effe wachten...
    152.         'klaar ga verder dan..
    153.         If CheckBoxX7.Checked = True Then
    154.             Try
    155.                 DownloadFile8(New Uri(sourceURL8), filedir)
    156.                 ProgressBarX8.Value = "100"
    157.             Catch ex As Exception
    158.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    159.  
    160.             End Try
    161.         End If
    162.         'effe wachten...
    163.         'klaar ga verder dan..
    164.         If CheckBoxX8.Checked = True Then
    165.             Try
    166.                 DownloadFile9(New Uri(sourceURL9), filedir)
    167.                 ProgressBarX9.Value = "100"
    168.             Catch ex As Exception
    169.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    170.  
    171.             End Try
    172.         End If
    173.         'effe wachten...
    174.         'klaar ga verder dan..
    175.         If CheckBoxX9.Checked = True Then
    176.             Try
    177.                 DownloadFile10(New Uri(sourceURL10), filedir)
    178.                 ProgressBarX10.Value = "100"
    179.             Catch ex As Exception
    180.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    181.  
    182.             End Try
    183.         End If
    184.         If ProgressBarX1.Value > "99" Then
    185.             NotifyIcon1.Icon = My.Resources.tick1
    186.             NotifyIcon1.Text = "Done - MC Downloader"
    187.             NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
    188.             NotifyIcon1.BalloonTipText = "Downloading finished"
    189.             NotifyIcon1.BalloonTipTitle = "MC Downloader"
    190.             NotifyIcon1.ShowBalloonTip(10000)
    191.             ProgressBarX1.Refresh()
    192.         End If

    a still no error in screen nothing. nothing in the debug window it just doesnt start downloading

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    any solution

  16. #16
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: wait

    You still haven't told us what the value of filedir was exactly when the exception was thrown. From your other posts, it looks like you're passing in a folder path to the DownloadFile method instead of a file path.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    thats what i want a folder path. the filenames of the downloads must stay intact

  18. #18
    Junior Member
    Join Date
    Jan 2009
    Posts
    30

    Re: wait

    If i am right you need to specify the folder and file of where you want to download to...

    such as:

    Code:
    DownloadFile1(New Uri(sourceURL), filedir & "\file1.rar")
    or something of the sorts

  19. #19
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: wait

    Quote Originally Posted by mmuziek View Post
    thats what i want a folder path. the filenames of the downloads must stay intact
    Then you have to parse the file name from you download url and append it to the save path. For example:
    Code:
    Dim url as string = "http://www.somedomain.com/downloadme.txt"
    'Since you already know what the download url is (otherwise, how are you going to download the file???), you simply parse that to get the filename.
    'In this example, the file name is everything after the last forward slash in the download url. So you just substring it to get the file name
    Dim filename as string = url.substring(url.LastIndexOf("/") + 1)
    'And append the file name to the folder path
    Dim saveTo as string = folderPath & "\" & filename
    myWebClient.DownloadFile(url, saveTo)
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    added it still it doesnt start any download it starts and finish the code but it doesnt download anything.

    ps. the progressbar doesnt work to with normal downloadfile command.

    well my code now:
    VB.net Code:
    1. Imports System.Net
    2. Public Class Form1
    3.     Private WithEvents httpclient As WebClient
    4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.  
    6.     End Sub
    7.     Public Sub DownloadFile1( _
    8.  ByVal sourceURL As Uri, _
    9.  ByVal filedir As String _
    10. )
    11.     End Sub
    12.     Public Sub DownloadFile2( _
    13.  ByVal sourceURL2 As Uri, _
    14.  ByVal filedir As String _
    15. )
    16.     End Sub
    17.     Public Sub DownloadFile3( _
    18.  ByVal sourceURL3 As Uri, _
    19.  ByVal filedir As String _
    20. )
    21.     End Sub
    22.     Public Sub DownloadFile4( _
    23.  ByVal sourceURL4 As Uri, _
    24.  ByVal filedir As String _
    25. )
    26.     End Sub
    27.     Public Sub DownloadFile5( _
    28.  ByVal sourceURL5 As Uri, _
    29.  ByVal filedir As String _
    30. )
    31.     End Sub
    32.     Public Sub DownloadFile6( _
    33.  ByVal sourceURL6 As Uri, _
    34.  ByVal filedir As String _
    35. )
    36.     End Sub
    37.     Public Sub DownloadFile7( _
    38.  ByVal sourceURL7 As Uri, _
    39.  ByVal filedir As String _
    40. )
    41.     End Sub
    42.     Public Sub DownloadFile8( _
    43.  ByVal sourceURL8 As Uri, _
    44.  ByVal filedir As String _
    45. )
    46.     End Sub
    47.     Public Sub DownloadFile9( _
    48.  ByVal sourceURL9 As Uri, _
    49.  ByVal filedir As String _
    50. )
    51.     End Sub
    52.     Public Sub DownloadFile10( _
    53.  ByVal sourceURL10 As Uri, _
    54.  ByVal filedir As String _
    55. )
    56.     End Sub
    57.  
    58.  
    59.     Private Sub ButtonItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem1.Click
    60.  
    61.         httpclient = New WebClient
    62.         Dim sourceURL = TextBoxX2.Text
    63.         Dim sourceURL2 = TextBoxX3.Text
    64.         My.Resources.gear.Save(My.Computer.FileSystem.SpecialDirectories.Temp & "\tempicon.ico", Imaging.ImageFormat.Icon)
    65.         NotifyIcon1.Icon = My.Resources.gear1
    66.         Refresh()
    67.         NotifyIcon1.Text = "Downloading in progress - MC Downloader"
    68.         NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
    69.         NotifyIcon1.BalloonTipText = "Downloading files"
    70.         NotifyIcon1.BalloonTipTitle = "MC Downloader"
    71.         NotifyIcon1.ShowBalloonTip(10000)
    72.         Dim sourceURL3 = TextBoxX4.Text
    73.         Dim sourceURL4 = TextBoxX5.Text
    74.         Dim sourceURL5 = TextBoxX6.Text
    75.         Dim sourceURL6 = TextBoxX7.Text
    76.         Dim sourceURL7 = TextBoxX8.Text 'v
    77.         Dim sourceURL8 = TextBoxX9.Text
    78.         Dim sourceURL9 = TextBoxX10.Text
    79.         Dim sourceURL10 = TextBoxX11.Text
    80.         Dim filedir As String = TextBoxX1.Text
    81.         filedir = TextBoxX1.Text
    82.         Try
    83.             Dim filename As String = sourceURL.Substring(sourceURL.LastIndexOf("/") + 1)
    84.             'And append the file name to the folder path
    85.             Dim saveTo As String = filedir & "\" & filename
    86.             DownloadFile1(New Uri(sourceURL), saveTo)
    87.             ProgressBarX2.Value = "100"
    88.         Catch ex As Exception
    89.             MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    90.  
    91.         End Try
    92.  
    93.         If CheckBoxX1.Checked = True Then
    94.             Try
    95.                 Dim filename As String = sourceURL2.Substring(sourceURL2.LastIndexOf("/") + 1)
    96.                 'And append the file name to the folder path
    97.                 Dim saveTo As String = filedir & "\" & filename
    98.  
    99.                 DownloadFile2(New Uri(sourceURL2), saveTo)
    100.                 ProgressBarX3.Value = "100"
    101.             Catch ex As Exception
    102.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    103.  
    104.             End Try
    105.         End If
    106.         'effe wachten...
    107.         'klaar ga verder dan..
    108.         If CheckBoxX2.Checked = True Then
    109.             Try
    110.                 Dim filename As String = sourceURL3.Substring(sourceURL3.LastIndexOf("/") + 1)
    111.                 'And append the file name to the folder path
    112.                 Dim saveTo As String = filedir & "\" & filename
    113.                 DownloadFile3(New Uri(sourceURL3), saveTo)
    114.                 ProgressBarX4.Value = "100"
    115.             Catch ex As Exception
    116.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    117.  
    118.             End Try
    119.         End If
    120.         'effe wachten...
    121.         'klaar ga verder dan..
    122.         If CheckBoxX3.Checked = True Then
    123.             Try
    124.                 Dim filename As String = sourceURL4.Substring(sourceURL4.LastIndexOf("/") + 1)
    125.                 'And append the file name to the folder path
    126.                 Dim saveTo As String = filedir & "\" & filename
    127.                 DownloadFile4(New Uri(sourceURL4), saveto)
    128.                 ProgressBarX5.Value = "100"
    129.             Catch ex As Exception
    130.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    131.  
    132.             End Try
    133.         End If
    134.         'effe wachten...
    135.         'klaar ga verder dan..
    136.         If CheckBoxX4.Checked = True Then
    137.             Try
    138.                 Dim filename As String = sourceURL5.Substring(sourceURL5.LastIndexOf("/") + 1)
    139.                 'And append the file name to the folder path
    140.                 Dim saveTo As String = filedir & "\" & filename
    141.                 DownloadFile5(New Uri(sourceURL5), saveTo)
    142.                 ProgressBarX6.Value = "100"
    143.             Catch ex As Exception
    144.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    145.  
    146.             End Try
    147.         End If
    148.         'effe wachten...
    149.         'klaar ga verder dan..
    150.         If CheckBoxX5.Checked = True Then
    151.             Try
    152.                 Dim filename As String = sourceURL6.Substring(sourceURL6.LastIndexOf("/") + 1)
    153.                 'And append the file name to the folder path
    154.                 Dim saveTo As String = filedir & "\" & filename
    155.                 DownloadFile6(New Uri(sourceURL6), saveTo)
    156.                 ProgressBarX7.Value = "100"
    157.             Catch ex As Exception
    158.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    159.  
    160.             End Try
    161.         End If
    162.         'effe wachten...
    163.         'klaar ga verder dan..
    164.         If CheckBoxX6.Checked = True Then
    165.             Try
    166.                 Dim filename As String = sourceURL7.Substring(sourceURL7.LastIndexOf("/") + 1)
    167.                 'And append the file name to the folder path
    168.                 Dim saveTo As String = filedir & "\" & filename
    169.                 DownloadFile7(New Uri(sourceURL7), saveTo)
    170.                 ProgressBarX8.Value = "100"
    171.             Catch ex As Exception
    172.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    173.  
    174.             End Try
    175.         End If
    176.         'effe wachten...
    177.         'klaar ga verder dan..
    178.         If CheckBoxX7.Checked = True Then
    179.             Try
    180.                 Dim filename As String = sourceURL8.Substring(sourceURL8.LastIndexOf("/") + 1)
    181.                 'And append the file name to the folder path
    182.                 Dim saveTo As String = filedir & "\" & filename
    183.                 DownloadFile8(New Uri(sourceURL8), saveTo)
    184.                 ProgressBarX9.Value = "100"
    185.             Catch ex As Exception
    186.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    187.  
    188.             End Try
    189.         End If
    190.         'effe wachten...
    191.         'klaar ga verder dan..
    192.         If CheckBoxX8.Checked = True Then
    193.             Try
    194.                 Dim filename As String = sourceURL9.Substring(sourceURL9.LastIndexOf("/") + 1)
    195.                 'And append the file name to the folder path
    196.                 Dim saveTo As String = filedir & "\" & filename
    197.                 DownloadFile9(New Uri(sourceURL9), saveTo)
    198.                 ProgressBarX10.Value = "100"
    199.             Catch ex As Exception
    200.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    201.  
    202.             End Try
    203.         End If
    204.         'effe wachten...
    205.         'klaar ga verder dan..
    206.         If CheckBoxX9.Checked = True Then
    207.             Try
    208.                 Dim filename As String = sourceURL10.Substring(sourceURL10.LastIndexOf("/") + 1)
    209.                 'And append the file name to the folder path
    210.                 Dim saveTo As String = filedir & "\" & filename
    211.                 DownloadFile10(New Uri(sourceURL10), saveto)
    212.                 ProgressBarX11.Value = "100"
    213.             Catch ex As Exception
    214.                 MsgBox("Failed " + ErrorToString(), MsgBoxStyle.Critical)
    215.  
    216.             End Try
    217.         End If
    218.         If ProgressBarX1.Value > "99" Then
    219.             NotifyIcon1.Icon = My.Resources.tick1
    220.             NotifyIcon1.Text = "Done - MC Downloader"
    221.             NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
    222.             NotifyIcon1.BalloonTipText = "Downloading finished"
    223.             NotifyIcon1.BalloonTipTitle = "MC Downloader"
    224.             NotifyIcon1.ShowBalloonTip(10000)
    225.             ProgressBarX1.Refresh()
    226.         End If
    227.     End Sub
    228.  
    229.     Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
    230.         Dim save As New FolderBrowserDialog
    231.         save.Description = "Download Directory"
    232.         save.ShowDialog()
    233.         TextBoxX1.Text = save.SelectedPath
    234.     End Sub
    235.  
    236.     Private Sub httpclient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles httpclient.DownloadFileCompleted
    237.  
    238.     End Sub
    239.     Private Sub httpclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
    240.         ProgressBarX1.Value = e.ProgressPercentage
    241.     End Sub

  21. #21
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: wait

    The code you posted does not have any code in the subs named DownloadFilex. So when you do this

    DownloadFilex(New Uri(sourceURL), saveTo)

    nothing should happen.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  22. #22
    Junior Member
    Join Date
    Jan 2009
    Posts
    30

    Re: wait

    I could be wrong but it doesn't look like your subs are doing anything.

    Code:
     Public Sub DownloadFile1( _ ByVal sourceURL As Uri, _ ByVal filedir As String _)    End Sub
    It looks to me like they are just stubs. Shouldn't there be more code in there? maybe something like:

    Code:
    Dim wc As New System.Net.WebClient
    wc.DownloadFile(uri, folder & "\" & file)

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    191

    Re: wait

    i fixed it completely with my friend Coi the best VB coder i can think off.

    hes great at coding and helped me live with it so i can continue my work.

    but all at once a conclusion
    i learned a lot in this topic thank u all!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width