GetFileInfo(string, FileInfoResult*)
Gets information about a file.
Read time 2 minutesLast updated 13 days ago
Definition
- Type: Method
- Namespace: Unity.IO.LowLevel.Unsafe
- Assembly: UnityEngine.CoreModule
public static ReadHandle GetFileInfo(string filename, FileInfoResult* result)
Parameters
The name of the file to query.
A struct that this function fills in with information about the file upon completion of this asynchronous request.
Returns
Type | Description |
|---|---|
| ReadHandle | A read handle that you can use to monitor the progress and status of this GetFileInfo command. |
Remarks
This function gets information about the specified file asynchronously without opening the file. On completion of the asynchronous operation, the parameter's FileInfoResult.FileState member reports whether the file exists (FileState.Exists) or not (FileState.Absent). If the file exists, the parameter's FileInfoResult.FileSize member reports the size of the file in bytes. If the file doesn't exist, the size is reported as zero.
resultresultGetFileInforesultresultWarning: A statement around the call pins the FileInfoResult only for the duration of its block, not for the asynchronous operation that continues after the block exits. This is a common mistake in methods, where the compiler places locals that outlive an on the managed heap. Pin the memory for the whole operation.
fixedGetFileInfoasyncawait