Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 2nd, 2009, 10:48 AM
Danbannan Danbannan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 4 Danbannan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 45 sec
Reputation Power: 0
Question Download a file and use SaveFileDialog.Filename

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

Reply With Quote
  #2  
Old October 2nd, 2009, 05:09 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
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

Reply With Quote
  #3  
Old October 5th, 2009, 10:05 AM
Danbannan Danbannan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 4 Danbannan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 45 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old October 7th, 2009, 06:22 PM
Danbannan Danbannan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 4 Danbannan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 45 sec
Reputation Power: 0
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 :-)

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Download a file and use SaveFileDialog.Filename


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek