FileExt.Read Method

Reads bytes 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<byte[]> Read(
	string uri,
	CancellationToken ct = default
)


Parameters

 

uri
Type: System.String
File full path to be opened for reading
ct (Optional)
Type: System.Threading.CancellationToken
Optional cancellation token, to be able to cancel the asynchronous operation

Return Value

Type: Task(Byte[])
Bytes read

Exceptions

ExceptionCondition
OperationCanceledExceptionTask canceled using ct
FileNotFoundExceptionThe file specified in uri was not found.
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