FileExt.TryReadText 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<(bool success, string text)> TryReadText(
	string uri,
	Encoding encoding = null,
	CancellationToken ct = default
)


Parameters

 

uri
Type: System.String
File location
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(ValueTuple(Boolean, String))
A pair describing a boolean success value and the text read

Remarks

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

See Also

Reference

FileExt Class
UltimateXR.Extensions.System.IO Namespace