Results 1 to 3 of 3

Thread: Need help regarding codeings

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    2

    Need help regarding codeings

    Hello all am just started to learn Vb.net

    am trying to make a downloader..it can download files from a link...i created treeview but am unable to get how to do this...can any one plz guide me with simple code...

    sample look like this...



    in this i want to download chilednode names .zip files from a link after click on childenode url must be open with savedialogbox...

    for splendor.zip consider https://www.vbforums.com/splendor.zip as link
    for delux.zip consider https://www.vbforums.com/delux.zip as link


    ignore download,resume,stop and pause buttons and progressbar



    Thanks in advance

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Need help regarding codeings

    When you add the treenode, for example splendor.zip, add the full url to the treenode tag, then you can retrieve the full url easily...

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim node As TreeNode = TreeView1.Nodes.Add("splendor.zip")
            node.Tag = "https://www.vbforums.com/splendor.zip"
            node = TreeView1.Nodes.Add("delux.zip")
            node.Tag = "https://www.vbforums.com/delux.zip"
        End Sub
    
        Private Sub TreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
            MsgBox(e.Node.Tag.ToString)
            Dim sfd As New SaveFileDialog  With { _
              .Title = "Choose file to save to", _
              .Filter = "ZIP (*.zip)|*.zip|All Files (*.*)|*.*", _
              .FilterIndex = 0, _
              .FileName = e.Node.Text, _
              .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}
            If sfd.ShowDialog = DialogResult.OK Then
                Dim wc As New Net.WebClient
                wc.DownloadFile(e.Node.Tag.ToString, sfd.FileName)
            End If
        End Sub
    
    End Class

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    2

    Re: Need help regarding codeings

    Quote Originally Posted by .paul. View Post
    When you add the treenode, for example splendor.zip, add the full url to the treenode tag, then you can retrieve the full url easily...

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim node As TreeNode = TreeView1.Nodes.Add("splendor.zip")
            node.Tag = "https://www.vbforums.com/splendor.zip"
            node = TreeView1.Nodes.Add("delux.zip")
            node.Tag = "https://www.vbforums.com/delux.zip"
        End Sub
    
        Private Sub TreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
            MsgBox(e.Node.Tag.ToString)
            Dim sfd As New SaveFileDialog  With { _
              .Title = "Choose file to save to", _
              .Filter = "ZIP (*.zip)|*.zip|All Files (*.*)|*.*", _
              .FilterIndex = 0, _
              .FileName = e.Node.Text, _
              .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}
            If sfd.ShowDialog = DialogResult.OK Then
                Dim wc As New Net.WebClient
                wc.DownloadFile(e.Node.Tag.ToString, sfd.FileName)
            End If
        End Sub
    
    End Class
    Thanks you sir...i will try it...

    wbr
    premras

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