-
Apr 7th, 2021, 06:06 AM
#1
Thread Starter
New Member
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
-
Apr 8th, 2021, 01:27 AM
#2
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
Last edited by .paul.; Apr 8th, 2021 at 02:24 AM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 8th, 2021, 09:56 AM
#3
Thread Starter
New Member
Re: Need help regarding codeings
Originally Posted by .paul.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|