In This Topic
The NFolder class contains properties and methods for working with folders in a platform independent way. In most cases you will work with one of the application Root Folders. When necessary you can also get a NFolder instance for a file system path, by using the GetFolder method of the NFileSystem class.
The methods of the NFolder class are organized into two major categories:
Folder and File Information
The following methods of the NFolder class provide information about the files and folders contained inside a specific folder:
Method |
Description |
NPromise<NFile[]> GetFilesAsync() |
Gets all files inside this folder. |
NPromise<NFile[]> GetFilesAsync(string searchPattern, ENFolderScanMode scanMode) |
Gets the child or descendant files that match the specified searchPattern. |
NPromise<NFolder[]> GetFoldersAsync() |
Gets all child folders of this folder. |
NPromise<NFolder[]> GetFoldersAsync(string searchPattern, ENFolderScanMode scanMode) |
Gets the child or descendant folders that match the specified searchPattern. |
NFile GetFile(string fileName) |
Gets a file, which is relative to this folder. |
NFolder GetFolder(string folderName) |
Gets a folder, which is relative to this folder. |
To get a file or a sub-folder of a given folder, it is recommended to use the GetFile and GetFolder methods respectively. For example, to get the file "MyFile.txt" from the folder "C:\Documents", you can use the following code:
Get a file from folder |
Copy Code
|
NFolder folder = NFileSystem.Current.GetFolder("C:\Documents");
NFile file = folder.GetFile("MyFile.txt");
|
Folder Manipulation and Information
The following methods of the NFolder class help you manipulate folders, as well as obtain information about them.
Method |
Description |
Folder Specific Operations
|
NPromise<NUndefined> CreateAsync() |
Ensures that the folder is created. |
NPromise<NUndefined> EmptyAsync() |
Deletes all files and folders in the folder. |
NPromise<NFolder> CopyAsync(string destinationPath, bool overrideDestination) |
Copies this folder to the specified destination. If specified, overrides the duplicate descendant files and folders in the destination. |
NPromise<NFolder> MoveAsync(string destinationPath, bool overrideDestination) |
Moves this folder to the specified destination. If specified, overrides the duplicate descendant files and folders in the destination. |
Inherited from NFileSystemObject
|
NPromise<NUndefined> DeleteAsync() |
Deletes the folder |
NPromise<bool> ExistsAsync() |
Checks whether the folder exists. |
NFolder GetParentFolder() |
Get the folder in which the folder resides. |
NPromise<ENFileSystemObjectAttributes> GetAttributes() |
Gets the attributes of this file or directory. |
NPromise<NUndefined> SetAttributes(ENFileSystemObjectAttributes attributes) |
Sets the attributes of this file or directory. |
NPromise<DateTime> GetTime(ENFileSystemObjectTime time) |
Gets the specifies file system object time stamp. |
NPromise<NUndefined> SetTime(ENFileSystemObjectTime time, DateTime value) |
Sets the specifies file system object time stamp. |
See Also