Field-Map Scripting

4.1.4.9 DeleteFile

DeleteFile function


Prototype:

function DeleteFile(const FilePath: string): boolean;

Description:

Use DeleteFile function to delete file in a specific directory.

Syntax:

variable := DeleteFile(FilePath);


Part

Description


variable

variable declared as boolean


Project

A reference to the Field-Map project as defined in Field-Map Project Manager


FilePath

A string parameter specifying the full location of the file


Return value:


True if the file was deleted OK, otherwise False



Example:

var

fileName, pathToFile: string;

checkDeleteFile: boolean;


begin

  fileName:= 'listOfTrees.txt';

  pathToFile:= SystemDir + fileName;    // SystemDir is predefined variable, returns path to the system folder, see Predefined variables


  checkDeleteFile:= DeleteFile(pathToFile);


  if checkDeleteFile = true then

    begin

      ShowMessage('The file "' + fileName + '" was deleted from ' + pathToFile);

    end

  else

    begin

ShowMessage('The file "' + fileName + '" not exists in the directory ' + pathToFile);

    end;

end.



Output in Field-Map Data Collector:

1)

if the file exists and it was deleted correctly



2)

if the file not exists or the file wasn't deleted


See also:

AssignFile; Reset; Rewrite; Append; WriteLn; ReadLn; EOF; CloseFile; DeleteFile; SaveStringToFile; SaveStringToFileAsUTF8