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
pathstringThe full path where the folder should be created.
Returns
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
pathstringThe 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
pathstringThe 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
pathstringThe 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
pathstringThe path to the folder.
Returns
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
pathstringThe path to the folder.
Returns
Exceptions
- ArgumentNullException
Thrown when path is null.
GetFolders(string?)
Gets all subfolders in the specified folder.
public static IFolderInfo[] GetFolders(string? path)
Parameters
pathstringThe 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
pathstringThe path to the folder.
Returns
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
pathstringThe path to the folder.
Returns
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
pathstringThe path to the folder.
Returns
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
pathstringThe path to the folder.
Returns
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
dataIFolderInfoThe folder information to get the parent of.
Returns
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
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
pathstringThe 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
pathstringThe path to the folder. If null, an exception will be thrown.
skipHiddenboolWhether 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
skipHiddenboolWhether 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
skipHiddenboolWhether 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
Returns
- bool
true if the folder was successfully renamed; otherwise, false.
Exceptions
- ArgumentNullException
Thrown when either parameter is null.