Skip to main content

DeviceFileSystem

Namespace: Wisej.Hybrid

Assembly: Wisej.Hybrid

Provides methods to interact with the device's file system, allowing you to perform various file-related operations.

public class DeviceFileSystem

Access this class through the FileSystem singleton.

Constructors​

Instance memberDeviceFileSystem()​

Initializes a new instance of DeviceFileSystem.

Properties​

The published 4.1.4 XML includes CacheDirectory, AppDataDirectory, Desktop, MyDocuments, ApplicationData, CommonDocuments, DesktopDirectory and LocalApplicationData. These are native client paths; access is subject to that device's sandbox and permissions.

Methods​

Instance memberCreateDirectory(path)​

Creates a directory at the given path.

ParameterTypeDescription
pathStringThe directory path to create.

Instance memberDeleteDirectory(path)​

Deletes the directory at the given path.

ParameterTypeDescription
pathStringThe directory path to delete.

Instance memberDeleteFile(path)​

Deletes the file at the given path.

ParameterTypeDescription
pathStringThe file path to delete.

Instance memberExists(path)​

Determines whether a file exists at the given path.

ParameterTypeDescription
pathStringThe file path to check.

Returns: Boolean. true if the file exists; otherwise, false.

Instance memberGetFiles(directory)​

Gets a list of file names in the specified directory.

ParameterTypeDescription
directoryStringThe directory path to query.

Returns: String[]. An array of file names in the directory.

Instance memberReadBytes(path)​

Reads the bytes from a file at the given path.

ParameterTypeDescription
pathStringThe file path to read from.

Returns: Byte[]. An array of bytes representing the file contents.

Instance memberReadText(path)​

Reads the text from a file at the given path.

ParameterTypeDescription
pathStringThe file path to read from.

Returns: String. The text content of the file.

Instance memberWriteBytes(path, bytes)​

Writes the provided bytes to a file at the given path.

ParameterTypeDescription
pathStringThe file path to write to.
bytesByte[]The bytes to write to the file.

Instance memberWriteText(path, contents)​

Writes the provided text to a file at the given path.

ParameterTypeDescription
pathStringThe file path to write to.
contentsStringThe text contents to write to the file.

Async methods​

The published 4.1.4 package XML also documents ExistsAsync(path), ReadBytesAsync(path), ReadTextAsync(path) and GetFilesAsync(directory). Await these when reading client files from async Wisej event handlers. The write methods are named WriteText and WriteBytes, not WriteAllText or WriteAllBytes.

See Basics and Email attachments for examples.