FileExt.ReadText Method
Reads text from a file asynchronously. Multiple file locations are supported:
- Files in streamingAssetsPath
- Files in an http:// location
- Files in a file:// location
Namespace: UltimateXR.Extensions.System.IO
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public static Task<string> ReadText(
string uri,
Encoding encoding = null,
CancellationToken ct = default
)
Parameters
- uri
- Type: System.String
File full path to be opened for reading - encoding (Optional)
- Type: System.Text.Encoding
Optional file encoding - ct (Optional)
- Type: System.Threading.CancellationToken
Optional cancellation token, to cancel the asynchronous operation
Return Value
Type: Task(String)
Text content of the file or a null reference (Nothing
in Visual Basic) if not found.
Exceptions
Exception | Condition |
---|---|
OperationCanceledException | Task canceled using ct |
NotSupportedException | uri is in an invalid format. |
IOException | An I/O error occurred while opening the file. |
InvalidOperationException | The stream is currently in use by a previous read operation. |
Remarks
UnityWebRequest.Get() is used internally to perform the actual reading