Difference between revisions of "File.delete"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "The <c>file.delete</c> method deletes a file or empty directory from disk. === Arguments === {| class="wikitable" |- ! Parameter Name !! Default Value !! Meaning |- | pa...")
 
m (fixed formatting)
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:
 
If the file was successfully deleted, this method returns [[true]] (1).
 
If the file was successfully deleted, this method returns [[true]] (1).
 
Otherwise, it returns [[false]] (0).  This can happen if the specified file does not exist, if it is a directory that is not empty, or if some other low-level issue occurs (for example, the file is locked).
 
Otherwise, it returns [[false]] (0).  This can happen if the specified file does not exist, if it is a directory that is not empty, or if some other low-level issue occurs (for example, the file is locked).
 +
 +
== Known Issue ==
 +
 +
In version 1.0 of Mini Micro, <c>file.delete</c> fails on a directory (even if empty), returning "Error: file not found".
  
 
== Example ==
 
== Example ==

Latest revision as of 01:09, 28 September 2021

The file.delete method deletes a file or empty directory from disk.

Arguments

Parameter Name Default Value Meaning
path "" file name, partial path, or absolute path to file or directory to be deleted

If given a file name or partial path, it will be interpreted relative to the current working directory (see file.curdir).

Result

If the file was successfully deleted, this method returns true (1). Otherwise, it returns false (0). This can happen if the specified file does not exist, if it is a directory that is not empty, or if some other low-level issue occurs (for example, the file is locked).

Known Issue

In version 1.0 of Mini Micro, file.delete fails on a directory (even if empty), returning "Error: file not found".

Example

The following attempts to delete a file called "test.txt" in the current directory.

file.delete "test.txt"