|Top Previous Next|
Manage files on flash storage.
There is both a global static File object and an instance File object that represents an open file or folder. For example, you open a file using the static File.open() function:
myFile = File.open(...);
Then you can operate on the resulting instance File object:
len = myFile.length;
An instance File object can refer to an open file or a folder. An open folder can be used as the starting point for finding another file or folder (similar to a "current directory" -- see below).
The static functions require you to specify a file or folder with a name string and optionally a folder. The name string may include folder names separated by '/' or '\' characters (note that '\' is the string escape character and must be written as '\\' in a literal string). To specify the root folder, use '/'.
The folder may be omitted or null if the name string specifies a file or folder relative the root folder. Or you can provide an instance File object that is an open folder and the name string will be relative that folder. For example:
dataFolder = File.open("data", File.openFolder | File.openAlways);
myDataFile = File.open("myFolder/myData.dat", File.openFile | File.createAlways, dataFolder);
// myDataFile is opened at \data\myFolder\myData.dat
dataFolder.close(); // myDataFile still open