How to delete some file from the ListView?
-
Hi, I have a ListView table that contains some files and i would like to know the command that will delete it by clicking some Delete Button. Thanks in advance for your help. Eyungwah
Probably you mean that
ListView
contains the path of the files. Then simply callFile.Delete
, passing the text of theListView
Items. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Hi, I have a ListView table that contains some files and i would like to know the command that will delete it by clicking some Delete Button. Thanks in advance for your help. Eyungwah
Well, you can use the
ListView.SelectedItems
property to retrieve a collection of all items that are currently selected. Iterate over the returned collection and for each item delete the respective file by using classes fromSystem.IO
namespace (if you really want to delete on the file system) and finally remove the item from the list view viaListView.Items.Remove
method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook