• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

Delete,Rename Files en delphi

as I can delete and rename files?

0
jara_vla
Asked:
jara_vla
1 Solution
 
edeyCommented:
try these:

Unit

SysUtils
DeleteFile deletes a file from disk, and returns False if the delete fails.

function DeleteFile(const FileName: string): Boolean;

Description

The DeleteFile function erases the file named by FileName from the disk. If the file cannot be deleted or does not exist, the function returns False.

Example

The following code erases the file DELETE.ME in the current directory:

DeleteFile('DELETE.ME');

and:


Unit

SysUtils

Category

File Management Routines
RenameFile changes a file name identified by OldName.

function RenameFile(const OldName, NewName: string): Boolean;

Description

The RenameFile function attempts to change the name of the file specified by OldFile to NewFile. If the operation succeeds, RenameFile returns True. If it cannot rename the file (for example, if a file called NewName already exists), it returns False.

Example

The following code renames a file:

if not RenameFile('OLDNAME.TXT','NEWNAME.TXT') then

  ErrorMsg('Error renaming file!');

this was also taken from the help file:

procedure TFMForm.ConfirmChange(const ACaption, FromFile, ToFile: string);
begin
  if MessageDlg(Format('%s %s to %s?', [ACaption, FromFile, ToFile]),
    mtConfirmation, [mbYes, mbNo], 0) = mrYes then
 begin
    if ACaption = 'Move' then
      MoveFile(FromFile, ToFile)
   else if ACaption = 'Copy' then
      CopyFile(FromFile, ToFile)
   else if ACaption = 'Rename' then
      RenameFile(FromFile, ToFile);

   FileList.Update;
  end;
end;


GL
Mike
0
 
jara_vlaAuthor Commented:
very thanks!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now