Difference between revisions of "File.delete"
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...") |
(added bug note) |
||
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, `file.delete` fails on a directory (even if empty), returning "Error: file not found". | ||
== Example == | == Example == |
Revision as of 01:09, 28 September 2021
The file.delete
method deletes a file or empty directory from disk.
Contents
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"