I am making a program to list all files in a listview (currently it lists the file name, file path, last access date, and size) in a specified directory, and I want the user to be able to select files using checkboxes, click a delete button, and see those files listed the same way on another form in a listbox. I've been able to get the first column of data (the file names) to be passed over to the second form but can't get the rest of the info to show up. The user should then be able to delete the files from here. I hope this makes sense...the code i'm using to pass the checked items is below. Any tips?
Private Sub DeleteBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteBtn.Click For Each unwantedFile As ListViewItem In FilesList.Items If unwantedFile.Text Is Nothing Then MessageBox.Show("You have not checked any items to be deleted", "Error") Else If unwantedFile.Checked = True Then DeleteForm.DeletionList.Items.Add(unwantedFile.Text) End If End If Next DeleteForm.Show() End Sub
Then the code I have to delete the files from the second form is below - somehow the types don't match up:
Private Sub DeleteBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteBtn.Click For Each file As ListViewItem In DeletionList.Items If file.Checked = True Then For Each item As String In DeletionList.Items IO.File.Delete(item) Next End If Next End Sub
I'm somewhat new to .net so any advice or pointers would be lovely. Thanks so much!