Table of Contents

Class GDDirectory

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

Represents a directory file.

public sealed class GDDirectory : GDFileBase, IDisposable
Inheritance
GDDirectory
Implements
Inherited Members

Properties

Attribute

The type of the item.

public override GDFileAttributes Attribute { get; protected set; }

Property Value

GDFileAttributes

Returns the type of attribute the item has.

Null: Indicates that the item is a representation of a null file.

File: Indicates that the item is a representation of a file.

Directory: Indicates that the item is a representation of a directory file.

Count

Subdirectory count.

public int Count { get; }

Property Value

int

Returns the number of subdirectories present in this directory.

Name

Item name.

public override string Name { get; }

Property Value

string

Returns the name of the item.

NameWithoutExtension

The name of the item without extension.

public override string NameWithoutExtension { get; }

Property Value

string

Returns the item name without its extension.

Parent

The item's parent GDFileBase.

public override GDFileBase Parent { get; protected set; }

Property Value

GDFileBase

Returns the parent GDFileBase that the item is affiliated with.

Path

The path of the item.

public override string Path { get; protected set; }

Property Value

string

Returns the full or relative path of the item.

Methods

CreateDirectory(string?)

Allows you to create a new directory.

public bool CreateDirectory(string? directoryName)

Parameters

directoryName string

The name of the new directory.

Returns

bool

Returns true if the directory was created successfully.

Exceptions

ArgumentNullException

The exception is thrown when string object is null.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public override void Dispose()

~GDDirectory()

The finalizer allows the disposal of unmanageable code.

protected ~GDDirectory()

GetDirectories()

Get all directories.

public GDDirectory[] GetDirectories()

Returns

GDDirectory[]

If no directory is found an empty list will be returned.

Remarks

Subdirectories of directories already obtained will not be included.

GetDirectory(string?, bool)

Gets a specific directory.

public GDDirectory? GetDirectory(string? relativePath, bool isSubdirectory = false)

Parameters

relativePath string

The name of the directory to search.

isSubdirectory bool

Allows the method to search subdirectories.

Returns

GDDirectory

Exceptions

ArgumentNullException

The exception is thrown when string object is null.

GetFile(string?, bool)

Gets a specific file.

public GDFile? GetFile(string? name, bool isSubdirectory = false)

Parameters

name string

The name of the file to search for.

isSubdirectory bool

Allows the method to search subdirectories.

Returns

GDFile

If the directory is not found, a GDDirectory marked as Null will be returned.

Exceptions

ArgumentNullException

The exception is thrown when string object is null.

GetFiles(bool)

Gets multiple files in the same directory.

public GDFile[] GetFiles(bool isSubdirectory = false)

Parameters

isSubdirectory bool

Allows the method to search subdirectories.

Returns

GDFile[]

If no files are found, an empty list will be returned.

GetGDDirectory()

Opens an existing directory of the filesystem.

public static GDDirectory? GetGDDirectory()

Returns

GDDirectory

GetGDDirectory(string?)

Opens an existing directory of the filesystem.

public static GDDirectory? GetGDDirectory(string? path)

Parameters

path string

The path argument can be within the project tree (res://folder), the user directory (user://folder) or an absolute path of the user filesystem (e.g. /tmp/folder or C:\tmp\folder).

Returns

GDDirectory

RemoveDirectory(string?)

Allows you to remove a specific directory.

public bool RemoveDirectory(string? directoryName)

Parameters

directoryName string

The directory to be removed.

Returns

bool

Returns true if the directory was deleted successfully.

Exceptions

ArgumentNullException

The exception is thrown when string object is null.

RemoveFile(string?)

Allows the removal of a specific file.

public bool RemoveFile(string? fileName)

Parameters

fileName string

The name of the file to be deleted.

Returns

bool

Returns true if the file was deleted successfully.

Exceptions

ArgumentNullException

The exception is thrown when string object is null.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.