This interface is implemented by File Manager object. It provides basic methods to work with a file system, like opening or creating files and folders, deleting files and folders and enumerating the contents of a folder.
interface IFileManager {
// Properties
readonly ${tempFolder}: string;
readonly ${windowsFolder}: string;
readonly ${systemFolder}: string;
readonly ${programDataFolder}: string;
// Methods
${createFile}(path: string,
openMode: ${FS.OpenMode},
access: ${FS.Access},
share?: ${FS.Share}): ${IFile};
${deleteFile}(path: string): void;
${enumFiles}(folder: string, mask?: string): Promise<string[]>;
${copyFile}(source: string, destination: string, overwrite?: boolean): Promise<void>;
${moveFile}(source: string, destination: string, overwrite?: boolean): Promise<void>;
${createFolder}(path: string): void;
${deleteFolder}(path: string): void;
${loadTextFile}(path: string, utf8?: boolean): string;
}
// This interface is not available in managed environment
// This interface is not available in native environment
readonly tempFolder: string;
// This property is not available in managed environment
// This property is not available in native environment
Get the system temporary folder. Usually equals to c:\Windows\TEMP
.
readonly windowsFolder: string;
// This property is not available in managed environment
// This property is not available in native environment
Get the OS root folder. Usually equals to c:\Windows
.
readonly systemFolder: string;
// This property is not available in managed environment
// This property is not available in native environment
Get the OS system folder. Usually equals to c:\Windows\System32
.
readonly programDataFolder: string;
// This property is not available in managed environment
// This property is not available in native environment
Get the ProgramData
folder. Usually equals to c:\ProgramData
.
createFile(path: string,
openMode: ${FS.OpenMode},
access: ${FS.Access},
share?: ${FS.Share}): ${IFile};
// This method is not available in managed environment
// This method is not available in native environment
path
openMode
access
share
FS.Share.Exclusive
.An opened file object.
Creates or opens a file.
Open an existing file for reading
var file = fileManager.createFile("c:\\temp\\file.txt", FS.OpenMode.OpenExisting, FS.Access.Read, FS.Share.Read);
deleteFile(path: string): void;
// This method is not available in managed environment
// This method is not available in native environment
path
Deletes a given file.
enumFiles(folder: string, mask?: string): Promise<string[]>;
// This method is not available in managed environment
// This method is not available in native environment
folder
mask
Enumerate files in a given folder. The method executes asynchronously and returns a list of file names that match a given mask.
Enumerating files in a folder
var files = await fileManager.enumFiles("c:\\temp", "*.txt");
copyFile(source: string, destination: string, overwrite?: boolean): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
source
destination
overwrite
false
.Copies a source file to destination. The method executes asynchronously.
Copying a file
await fileManager.copyFile(source, destination);
moveFile(source: string, destination: string, overwrite?: boolean): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
source
destination
overwrite
false
.Moves a source file to destination or renames a file. The method executes asynchronously.
Renaming a file
await fileManager.moveFile(source, destination);
createFolder(path: string): void;
// This method is not available in managed environment
// This method is not available in native environment
path
Creates a folder. If one or more intermediate folders in a given path do not exist, they are also created by this function.
deleteFolder(path: string): void;
// This method is not available in managed environment
// This method is not available in native environment
path
Deletes a given folder. A folder must be empty to be successfully deleted.
loadTextFile(path: string, utf8?: boolean): string;
// This method is not available in managed environment
// This method is not available in native environment
path
utf8
true
if omitted.This method attempts to load and parse a text file. It tries to automatically determine the text file encoding by analyzing its structure and presence of BOM at the beginning of a file.