allowReplace

Type: Boolean

The allowReplace property of the File class specifies whether a file can be overwritten when it is opened. For example, if the value of the allowReplace property is false and a file is opened in output mode (that is, the mode property has a value of File.Mode_Output) and a file of the same name already exists, the file is not overwritten and an exception is raised.

The default value is true; that is, the file can be overwritten if it already exists.

The value is ignored if the file is already open.

The code fragment in the following example shows the use of the allowReplace property when using the File class extractSort method to sort a file and replace the file with the output of the sort. The result of the sort is then written to the text box.

file.allowReplace := true;
file.extractSort(sortActorArray, file);
textBox2.text := file.readString(400);
resetOutputFile;
file.close;