Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Firstly i am sorry if this is wrong section.

 

I have only just switched over from vb6 to vb.net(was beginner at vb6) & am trying to look for some source to learn from on file scan.

 

I wont to be able to scan say the c:\ for .jpg or something then have it listed in a list box,

 

Then be able to choose to either delete selected file or the entier group.

 

Thanks,

Posted

To display the results in a list box control you can do this.

 

'PD code:
dim files() as string = System.io.directory.getfiles("c:\", "*.jpg")

ListBox1.DataSource = files

 

Then you can drop this code behind your delete button

 

System.IO.File.Delete(ListBox1.SelectedItem)

 

Use caution when using this code as it will not put the deleted item into the Recycling Bin, once you delete it, it's gone.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

what is wrong with this???

 

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

       System.IO.File.Delete(ListBox1.SelectedItem)
       ListBox1.Items.RemoveAt(1)



   End Sub

 

I want to remove the list box entry,

Posted
Check to see if the index of the Items is out of the boundaries, i.e. there may be one and only one item in the collection (whose index is zero-based), and you are attempting to access "nothing" at index 1...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...