I have a ListBox which contain and display individual xml files. The archived files are accumulating and I need to implement a delete button to permanently delete the selected xml files.
The files are stored within the folder named “Archive” folder (please see screenshot) .
How do I implement the solution? I have the following code behind for my delete button. The code is working by deleting the records within the memory, however it couldn’t delete the actual file, each time the page loads the files are still there. I appreciate your help. Thanks.
protected void DeleteValues(object sender, EventArgs e)
{
List<ListItem> deletedItems = new List<ListItem>();
foreach (ListItem item in ListBoxArchive.Items)
{
if (item.Selected)
{
deletedItems.Add(item);
}
}
foreach (ListItem item in deletedItems)
{
ListBoxArchive.Items.Remove(item);
}
}
https://codeshare.io/aWnMF – Jan 23 '16 at 21:35