Table of Contents

Class Folder

Namespace
Cobilas.GodotEngine.Utility.IO
Assembly
com.cobilas.godot.utility.dll

Provides static methods for working with folders and directories in both Godot and system file systems.

public static class Folder
Inheritance
Folder
Inherited Members

Remarks

This class offers a unified interface for folder operations that works seamlessly across Godot's virtual file system and the underlying operating system's file system.

Properties

LogicalDrives

Gets the logical drives available on the system.

public static string[] LogicalDrives { get; }

Property Value

string[]

An array of strings representing the logical drives (e.g., "C:", "D:").

Methods

Create(string?)

Creates a new folder at the specified path.

public static IDataInfo Create(string? path)

Parameters

path string

The full path where the folder should be created.

Returns

IDataInfo

An IDataInfo instance representing the newly created folder.

Exceptions

ArgumentNullException

Thrown when path is null.

Delete(string?)

Deletes the folder at the specified path and all its contents.

public static bool Delete(string? path)

Parameters

path string

The path to the folder to delete.

Returns

bool

true if the folder was successfully deleted; otherwise, false.

Remarks

This method will not delete internal Godot folders. If the path is empty or null, the operation will return false without throwing an exception.

Exceptions

ArgumentNullException

Thrown when path is null.

Exists(string?)

Determines whether the specified folder exists.

public static bool Exists(string? path)

Parameters

path string

The path to check for existence.

Returns

bool

true if the folder exists; otherwise, false.

Remarks

This method works with both system directories and Godot's virtual file system.

Exceptions

ArgumentNullException

Thrown when path is null.

GetArchives(string?)

Gets all archive files in the specified folder.

public static IArchiveInfo[] GetArchives(string? path)

Parameters

path string

The path to search for archive files.

Returns

IArchiveInfo[]

An array of IArchiveInfo representing the archive files found.

Exceptions

ArgumentNullException

Thrown when path is null.

GetCreationTime(string?)

Gets the creation time of the specified folder in local time.

public static DateTime GetCreationTime(string? path)

Parameters

path string

The path to the folder.

Returns

DateTime

A DateTime representing the folder's creation time in local time.

Exceptions

ArgumentNullException

Thrown when path is null.

GetCreationTimeUtc(string?)

Gets the creation time of the specified folder in UTC time.

public static DateTime GetCreationTimeUtc(string? path)

Parameters

path string

The path to the folder.

Returns

DateTime

A DateTime representing the folder's creation time in UTC.

Exceptions

ArgumentNullException

Thrown when path is null.

GetFolders(string?)

Gets all subfolders in the specified folder.

public static IFolderInfo[] GetFolders(string? path)

Parameters

path string

The path to search for subfolders.

Returns

IFolderInfo[]

An array of IFolderInfo representing the subfolders found.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastAccessTime(string?)

Gets the last access time of the specified folder in local time.

public static DateTime GetLastAccessTime(string? path)

Parameters

path string

The path to the folder.

Returns

DateTime

A DateTime representing the folder's last access time in local time.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastAccessTimeUtc(string?)

Gets the last access time of the specified folder in UTC time.

public static DateTime GetLastAccessTimeUtc(string? path)

Parameters

path string

The path to the folder.

Returns

DateTime

A DateTime representing the folder's last access time in UTC.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastWriteTime(string?)

Gets the last write time of the specified folder in local time.

public static DateTime GetLastWriteTime(string? path)

Parameters

path string

The path to the folder.

Returns

DateTime

A DateTime representing the folder's last write time in local time.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastWriteTimeUtc(string?)

Gets the last write time of the specified folder in UTC time.

public static DateTime GetLastWriteTimeUtc(string? path)

Parameters

path string

The path to the folder.

Returns

DateTime

A DateTime representing the folder's last write time in UTC.

Exceptions

ArgumentNullException

Thrown when path is null.

GetParent(IFolderInfo?)

Gets the parent folder of the specified folder information.

public static IDataInfo GetParent(IFolderInfo? data)

Parameters

data IFolderInfo

The folder information to get the parent of.

Returns

IDataInfo

An IDataInfo representing the parent folder, or Null if there is no parent.

Exceptions

ArgumentNullException

Thrown when data is null.

Move(string?, string?)

Moves a folder to a new location.

public static bool Move(string? path, string? destinationPath)

Parameters

path string

The current path of the folder.

destinationPath string

The new path for the folder.

Returns

bool

true if the folder was successfully moved; otherwise, false.

Exceptions

ArgumentNullException

Thrown when either path is null.

Open(string?)

Opens a folder at the specified path, automatically skipping hidden items.

public static IFolderInfo Open(string? path)

Parameters

path string

The path to the folder. If null, an exception will be thrown.

Returns

IFolderInfo

An IFolderInfo instance representing the opened folder.

Exceptions

ArgumentNullException

Thrown when path is null.

Open(string?, bool)

Opens a folder at the specified path with the option to skip hidden items.

public static IFolderInfo Open(string? path, bool skipHidden)

Parameters

path string

The path to the folder. If null, an exception will be thrown.

skipHidden bool

Whether to skip hidden files and folders in the enumeration.

Returns

IFolderInfo

An IFolderInfo instance representing the opened folder.

Exceptions

ArgumentNullException

Thrown when path is null.

OpenRes()

Opens the Godot resource path folder, automatically skipping hidden items.

public static IFolderInfo OpenRes()

Returns

IFolderInfo

An IFolderInfo instance representing the Godot resource folder.

OpenRes(bool)

Opens the Godot resource path folder with the option to skip hidden items.

public static IFolderInfo OpenRes(bool skipHidden)

Parameters

skipHidden bool

Whether to skip hidden files and folders in the enumeration.

Returns

IFolderInfo

An IFolderInfo instance representing the Godot resource folder.

OpenUser()

Opens the Godot user data path folder, automatically skipping hidden items.

public static IFolderInfo OpenUser()

Returns

IFolderInfo

An IFolderInfo instance representing the Godot user data folder.

OpenUser(bool)

Opens the Godot user data path folder with the option to skip hidden items.

public static IFolderInfo OpenUser(bool skipHidden)

Parameters

skipHidden bool

Whether to skip hidden files and folders in the enumeration.

Returns

IFolderInfo

An IFolderInfo instance representing the Godot user data folder.

Rename(string?, string?)

Renames a folder.

public static bool Rename(string? folderPath, string? newName)

Parameters

folderPath string

The current full path of the folder.

newName string

The new name for the folder.

Returns

bool

true if the folder was successfully renamed; otherwise, false.

Exceptions

ArgumentNullException

Thrown when either parameter is null.