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
  All other Uris will be considered file paths and the file:// location will be added.

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

ExceptionCondition
OperationCanceledExceptionTask canceled using ct
NotSupportedExceptionuri is in an invalid format.
IOExceptionAn I/O error occurred while opening the file.
InvalidOperationExceptionThe stream is currently in use by a previous read operation.

Remarks

UnityWebRequest.Get() is used internally to perform the actual reading

See Also

Reference

FileExt Class
UltimateXR.Extensions.System.IO Namespace