Class FileExtensions
Inheritance
Inherited Members
Namespace: Snowflake.Filesystem
Assembly: Snowflake.Framework.dll
Syntax
public static class FileExtensions
Methods
ReadAllText(IReadOnlyFile)
Opens a text file, reads all the text in the file into a string, and then closes the opened stream. The default encoding is UTF8.
Declaration
public static string ReadAllText(this IReadOnlyFile this)
Parameters
| Type | Name | Description |
|---|---|---|
| IRead |
this | The IFile to read. |
Returns
| Type | Description |
|---|---|
| System. |
A string containing all text in the file. |
ReadAllText(IReadOnlyFile, Encoding)
Opens a text file, reads all the text in the file into a string with the specified encoding, and then closes the opened stream.
Declaration
public static string ReadAllText(this IReadOnlyFile this, Encoding encoding)
Parameters
| Type | Name | Description |
|---|---|---|
| IRead |
this | The IFile to read. |
| System. |
encoding | The encoding applied to the contents of the file. |
Returns
| Type | Description |
|---|---|
| System. |
A string containing all text in the file. |
WriteAllText(IFile, String)
Opens a text file, writes all the text in the file into a string, and then closes the opened stream. The default encoding is UTF8.
If the file already exists, it is overwritten.
Declaration
public static void WriteAllText(this IFile this, string contents)
Parameters
| Type | Name | Description |
|---|---|---|
| IFile | this | The IFile to read. |
| System. |
contents | The contents to write to file. |
WriteAllText(IFile, String, Encoding)
Opens a text file, writes all the text in the file into a string with the specified encoding, and then closes the opened stream. If the file already exists, it is overwritten.
Declaration
public static void WriteAllText(this IFile this, string contents, Encoding encoding)
Parameters
| Type | Name | Description |
|---|---|---|
| IFile | this | The IFile to read. |
| System. |
contents | The contents to write to file. |
| System. |
encoding | The encoding applied to the contents of the file. |
WriteAllTextAsync(IFile, String)
Opens a text file, writes all the text in the file into a string asynchronously, and then closes the opened stream. The default encoding is UTF8.
If the file already exists, it is overwritten.
Declaration
public static Task WriteAllTextAsync(this IFile this, string contents)
Parameters
| Type | Name | Description |
|---|---|---|
| IFile | this | The IFile to read. |
| System. |
contents | The contents to write to file. |
Returns
| Type | Description |
|---|---|
| System. |
A string containing all text in the file. |
WriteAllTextAsync(IFile, String, Encoding)
Opens a text file, writes all the text in the file into a string with the specified encoding, and then closes the opened stream. If the file already exists, it is overwritten.
Declaration
public static Task WriteAllTextAsync(this IFile this, string contents, Encoding encoding)
Parameters
| Type | Name | Description |
|---|---|---|
| IFile | this | The IFile to read. |
| System. |
contents | The contents to write to file. |
| System. |
encoding | The encoding applied to the contents of the file. |
Returns
| Type | Description |
|---|---|
| System. |
A string containing all text in the file. |