And you want to save the information and reload it on startup or what?
ok if u didnt get by wat i ment by title i will explain xD
im tryin to make a downloader type thing where i can put the downloadable files in a list box an have it download to where u save it to .. if u need to know lil bit more i try to explain thnks for the help
Like so
![]()
Last edited by pushdis15; 04-07-2011 at 04:10 AM.
PlayStation ID:Boxing509
Originally Posted by pushdis15
And you want to save the information and reload it on startup or what?
eh dont know how to explain i want it where i can save like alot of files to like a listbox where i can download the selected file @Blubb1337
Last edited by pushdis15; 04-07-2011 at 04:14 AM.
PlayStation ID:Boxing509
Originally Posted by pushdis15
So you mean add a new link to the listbox? And then download the selected item from the listbox when the user presses the button?
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
yea thats wat i mean @Jason
PlayStation ID:Boxing509
Originally Posted by pushdis15
Keep an independent list of stuff. In C#, you'd do it like so:
Sorry for the non-tabbing, did it on phone which has no tab key.Code:List<KeyValuePair<string, string>> items = new List<KeyValuePair<string, string>>(); void PopulateItems() { foreach (KeyValuePair<string, string> item in items) ListBox1.Items.Add(item.Key); } void DownloadLinks() { foreach (KeyValuePair<string, string> item in items) (new WebClient()).DownloadFile("C:\Dest", item.Value); // example download code. replace with yours. } void DownloadSelectedLink() { foreach (KeyValuePair<string, string> item in items) if (ListBox1.SelectedText == item.Key) { (new WebClient()).DownloadFile("C:\Dest", item.Value); // example download code. replace with yours. break; } } void AddItem(string name, string URL) { items.Add(new KeyValuePair<string, string>(name, URL); }
edit: why am i spoonfeeding? :/
Last edited by freedompeace; 04-07-2011 at 04:32 AM.
if you want it to go to a download link then do this:
that will work if you want it to take you to a download linkCode:If Listbox1.SelectedItem = "put what item you want here" Then Try Process.Start("put the download link in here") Catch ex As Exception End Try End If
Well, the listbox control doesn't have any features to allow you to have a displayed entry and a secondary value
i.e your current listbox has
SnowBird Webbrowser.zip
But the link is obviously not that. The way I would handle this problem is to use a dictionary(Of String, String)
Here's an example I wrote up quickly:
First, the dictionary:
[highlight=vb.net]
Private linkDictionary As New Dictionary(Of String, String)
[/highlight]
Now declare the following methods:
[highlight=vb.net]
Private Sub updateListBox(ByVal lBox As ListBox, ByVal vals As Dictionary(Of String, String))
lBox.Items.Clear()
For Each kvp As KeyValuePair(Of String, String) In vals
lBox.Items.Add(kvp.Key)
Next
End Sub
Private Sub addToListBox(ByVal lBox As ListBox, ByVal display As String, ByVal link As String, ByRef vals As Dictionary(Of String, String))
Try
vals.Add(display, link)
updateListBox(lBox, vals)
Catch keyNfound As ArgumentException
If keyNfound.Message.ToLower.Contains("already been added") Then MessageBox.Show("An item with that name is already in the listbox, please pick a unique name!", "Error: Duplicate entry", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub removeFromListBox(ByVal lBox As ListBox, ByVal curItem As String, ByRef vals As Dictionary(Of String, String))
vals.Remove(curItem)
updateListBox(lBox, vals)
End Sub
[/highlight]
Now you just use those methods to do what they say:
i.e to add an item to the listbox
[highlight=vb.net]
addToListBox(ListBox1, "Hello.zip", "https://www.example.com/files/hello.zip", linkDictionary)
[/highlight]
to remove an item from the listbox:
[highlight=vb.net]
removeFromListBox(ListBox1, ListBox1.SelectedItem.ToString, linkDictionary)
[/highlight]
to get the link associated with the current file:
[highlight=vb.net]
MessageBox.Show(getValue(ListBox1.SelectedItem.ToS tring, linkDictionary))
[/highlight]
So to download you would simply download the 'getValue' result.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
thats what i did but it not showing up in the list box im trying to get it from my desktop as a location but it not workingCode:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim location As String Dim ofd As New SaveFileDialog ofd.Filter = "*.zip|*.zip|*.rar|*.rar" ofd.FileName = "Download" If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then Dim lvi As New ListViewItem(ofd.FileName) location = (ofd.FileName) My.Computer.Network.DownloadFile(" " + ListBox1.SelectedItem.ToString, location) End If log1.Items.Add("Item " + ListBox1.SelectedItem.ToString + " Was Downloaded") end sub end class
Last edited by pushdis15; 04-07-2011 at 04:55 AM.
PlayStation ID:Boxing509
Originally Posted by pushdis15
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
thats not all my code thats the savefiledialog i pasted the wrong code D: aww forget bout it / close plz @Jason
Last edited by pushdis15; 04-07-2011 at 05:12 AM.
PlayStation ID:Boxing509
Originally Posted by pushdis15
I would of just put the link in tag ;P ..
my blue file class held in tag for some time... never found the limit of it
I just like programming, that is all.
Current Stuff:
- GPU Programmer (Cuda)
- Client/Server (Cloud Server)
- Mobile App Development
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)