Skip to main content

File Class

NuGet: GHIElectronics.TinyCLR.IO
Assembly: GHIElectronics.TinyCLR.IO
Namespace: System.IO

Static helpers for file management — copy, move, delete, exists, open. Mirrors the .NET BCL System.IO.File API for the file-system mount points registered via GHIElectronics.TinyCLR.IO.FileSystem.

public static class File

Methods​

Copy(string sourceFileName, string destFileName)​

public static void Copy(string sourceFileName, string destFileName)

Copies a file to a new path; throws if the destination already exists.

Copy(string sourceFileName, string destFileName, bool overwrite)​

public static void Copy(string sourceFileName, string destFileName, bool overwrite)

Copies a file to a new path, optionally overwriting an existing destination.

Create(string path)​

public static FileStream Create(string path)

Creates or overwrites a file and returns a read/write stream to it.

Returns FileStream

Create(string path, int bufferSize)​

public static FileStream Create(string path, int bufferSize)

Creates or overwrites a file with the given buffer size and returns a read/write stream to it.

Returns FileStream

Delete(string path)​

public static void Delete(string path)

Deletes the file at the path; succeeds silently if it does not exist.

Exists(string path)​

public static bool Exists(string path)

Returns whether a file exists at the path.

Returns bool

Open(string path, FileMode mode)​

public static FileStream Open(string path, FileMode mode)

Opens a file with the given mode and returns a stream to it.

Returns FileStream

Open(string path, FileMode mode, FileAccess access)​

public static FileStream Open(string path, FileMode mode, FileAccess access)

Opens a file with the given mode and access and returns a stream to it.

Returns FileStream

Open(string path, FileMode mode, FileAccess access, FileShare share)​

public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)

Opens a file with the given mode, access, and sharing and returns a stream to it.

Returns FileStream

GetAttributes(string path)​

public static FileAttributes GetAttributes(string path)

Returns the attributes of the file at the path.

Returns FileAttributes

SetAttributes(string path, FileAttributes fileAttributes)​

public static void SetAttributes(string path, FileAttributes fileAttributes)

Sets the attributes of the file at the path.

OpenRead(string path)​

public static FileStream OpenRead(string path)

Opens an existing file for reading and returns a stream to it.

Returns FileStream

OpenWrite(string path)​

public static FileStream OpenWrite(string path)

Opens or creates a file for writing and returns a stream to it.

Returns FileStream

ReadAllBytes(string path)​

public static byte[] ReadAllBytes(string path)

Reads the entire contents of a file into a byte array.

Returns byte[]

WriteAllBytes(string path, byte[] bytes)​

public static void WriteAllBytes(string path, byte[] bytes)

Creates or overwrites a file and writes the byte array to it.

Move(string sourceFileName, string destFileName)​

public static void Move(string sourceFileName, string destFileName)

Moves a file to a new location and name.