|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there, im completely new to VB and im trying to learn myself how to download a file and use the SaveFileDialog with it. I cant see what im doing wrong
Please help me with this one dear community, btw, great forum :-) Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFileName As String
strFileName = SaveFD.FileName
SaveFD.InitialDirectory = "C:\"
SaveFD.Title = textbox.Text
SaveFD.Filter = "All Files|*.*"
SaveFD.ShowDialog()
If My.Computer.Network.IsAvailable Then
If My.Computer.Network.Ping("74.125.67.100") Then
MsgBox("Access Granted")
My.Computer.Network.DownloadFile(textbox.Text, strFileName)
Else
MsgBox("ERROR")
End If
End If
End Sub
End Class
What am i doing wrong here? i get the error: Argument cannot be Nothing. Parameter name: destinationFileName I guess its pretty simple but i cant figure it out ![]() Last edited by Danbannan : October 2nd, 2009 at 10:51 AM. Reason: Forgot some details |
|
#2
|
|||
|
|||
|
Error might be generated because need to qualify reference to the textbox with form name or the Me alias. Try Me.textbox.Text. Recommend you give textbox a more descriptive name such as tbxDestFileName
|
|
#3
|
|||
|
|||
|
Solved
Thanks for the input :-)
I have worked some more, and figured out that part. Now im doing the download from a listbox with added links. Ok, so i have an almost working program here, i stumbled upon a error i cant seem to figure out, so dear community, i seek your help again. Code:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Startnumber As Integer
Dim Endnumber As Integer
Dim i As Integer
Startnumber = ListBox1.TopIndex
Endnumber = ListBox1.Items.Count
For i = Startnumber To Endnumber
My.Computer.Network.DownloadFile(ListBox1.Items.It em(1), "C:\test" & i & ".zip", "", "", True, 100, True)
MsgBox("Download of " & i)
ListBox1.Items.RemoveAt(1)
Next i
End Sub
I cant seem to figure this out, it starts to download the first file in the listbox, and nr2, nr3, nr4, nr5, nr6, When it comes to nr7 the program stops working an i get an error that says (InvalidArgument=Value of '1' is not valid for 'index'. Parameter name: index) it points to this line: My.Computer.Network.DownloadFile(ListBox1.Items.It em(1), "C:\test" & i & ".zip", "", "", True, 100, True) How come? I feel im getting closer to make my downloader tho, my first program :-) Again, i would appreciate help greatly!! Edit: SOLVED! Zero count based ofcourse :-) Last edited by Danbannan : October 5th, 2009 at 11:37 AM. Reason: SOLVED |
|
#4
|
|||
|
|||
|
Ok, so i have yet stumpled upon a little case here, im trying to let the download try to download the file, wait for some time and try to download it again, and wait more if it cant and download it again, until it can (rapidshare, just for fun and nothing else, illegal?) The thing with free accounts is that you have to wait a certain time before and after downloads. So i will make a program do this for me. I can add many downloads from rapidshare and the program downloads it for me when it have access. So how can a make this try loop. Im pretty new to this so i havent gotten a working example yet, i have managed to download series of files after each other reading links from a listbox, pretty cool tho :-) If you guys want i can share the entire code for the download button :-)
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Download a file and use SaveFileDialog.Filename |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|