Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Files with Delphi 1

Status
Not open for further replies.

ZeeNer

Programmer
Jun 2, 2002
38
CA
Im making a save/loading engine for one of my application... This one found all the *.save files and add it into a listbox... so you can save and load very fast... but i want to allow the suppression of save files in that interface... but i don't know the way to delete a file in delphi... i look in the help but i found nothing... so please help me ! (sorry for my english :p)
 
If you mean "delete a file" from the disk, you can use something like this:
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if DeleteFile('c:\Delete.me') then
    ShowMessage('File Deleted')
  else
    ShowMessage('File NOT deleted');  
end;
If you meand "delete a file" name from a list box, you can use something like this:
Code:
procedure TForm1.Button2Click(Sender: TObject);
var
  i:integer;
begin
  i := ListBox1.Items.IndexOf('FileB.TXT');
  ListBox1.Items.Delete(i);
end;
If you mean something else, please post again with a more detailed explanation of what you need.
 
If you want also the Windows Shell support (Recycle Bin, Explorer like user interface, undo capabilities), you can use the SHFileOperation function found in ShellApi unit.
For more information about SHFileOperation, you can visit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top