Click or drag to resize
GDFileIOReadTextAsync Method (IGDStorageFile)
Reads the contents of the specified file and returns text.

Namespace:  GD
Assembly:  GD (in GD.dll) Version: 255.255.255.255
Syntax
public static IAsyncOperation<string> ReadTextAsync(
	IGDStorageFile file
)

Parameters

file
Type: GDIGDStorageFile
The file to read.

Return Value

Type: IAsyncOperationString
When this method completes successfully, it returns the contents of the file as a text string.
Remarks
Any object that implements the IGDStorageFile interface may be passed to this method through the file parameter. This method uses the character encoding of the specified file. If you want to specify different encoding, call ReadTextAsync(IGDStorageFile, UnicodeEncoding) instead.
Examples
The following example shows how to read text from file in the SDK secure storage.
using GD;
...
try
{
    var file = await GDWindows.Instance.SecureFolder.GetFileAsync("foo.bar");
    if (file != null)
    {
        string text = await GDFileIO.ReadTextAsync(file);
        // Perform additional tasks
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
    // For example, handle file not found
}
See Also