An example is a list of files uploaded to the listbox:

C:\Users\Tatyana\Desktop\ts\1.txt C:\Users\Tatyana\Desktop\test2\2.mp3 C:\Users\Tatyana\Desktop\file\backup\4.pdf 

When you click on the button, you need to delete all these files.

I tried to do this, but it’s not convenient, because every time you need to select - the path to the file and press the button.

 DeleteFile(ListBox1.Items[ListBox1.ItemIndex]); 

    1 answer 1

    Cycle through the list.

     For i:=0 to ListBox1.Items.Count-1 do begin DeleteFile(ListBox1.Items[i]); end; 
    • It worked, but I realized that I need to add a cycle (-1), that is, so ListBox1.Items.Count-1. Whatever the error List Index out of bounds (1). - Tatiana
    • one
      Yes exactly. - LLENN