Directory
Struct · namespace System
struct DirectoryDirectories and file names.
if (!Directory.Exists("out")) Directory.Create("out");var sources = Directory.FindFiles("src", ".cshift");string file = Path.Combine("src", "main.cshift");Directory operations use the C library (opendir/readdir/mkdir, which MinGW-w64 provides on Windows as well). Paths may use ‘/’ or ’'.
Static methods
Section titled “Static methods”| Name | Description |
|---|---|
GetCurrentDirectory |
The current working directory, with ‘/’ separators. |
Exists |
Whether a directory exists at path. |
Create |
Creates a directory, including missing parents. |
Delete |
Deletes an empty directory, or with recursive a directory with everything in it. |
Move |
Moves (renames) a directory; the target must not exist. |
GetEntries |
The names of the files and directories in a directory (not the paths, without . and ..), sorted. |
FindFiles |
All files below a directory (recursively) whose name ends with the extension (“.cshift”; empty = all files). |
GetCurrentDirectory
Section titled “GetCurrentDirectory”static string GetCurrentDirectory()The current working directory, with ‘/’ separators.
Since 0.04
Exists
Section titled “Exists”static bool Exists(StringSlice path)Whether a directory exists at path.
Create
Section titled “Create”static bool Create(StringSlice path)Creates a directory, including missing parents.
Returns whether the directory exists afterwards.
Delete
Section titled “Delete”static IoError<void> Delete(StringSlice path, bool recursive)Deletes an empty directory, or with recursive a directory with everything in it.
Errors
IoError.CannotOpen: the directory does not exist.IoError.CannotDelete: it cannot be deleted (withoutrecursive: it is not empty).
Since 0.19
static IoError<void> Delete(StringSlice path)Deletes an empty directory.
Errors
IoError.CannotOpen: the directory does not exist.IoError.CannotDelete: it cannot be deleted (it is not empty, no permission).
Since 0.19
static IoError<void> Move(StringSlice source, StringSlice target)Moves (renames) a directory; the target must not exist.
Errors
IoError.CannotOpen:sourcedoes not exist.IoError.AlreadyExists:targetexists.IoError.CannotMove: the system refused (another drive on AmigaOS, no permission).
Since 0.19
GetEntries
Section titled “GetEntries”static List<string> GetEntries(StringSlice path)The names of the files and directories in a directory (not the paths, without . and ..), sorted.
Returns an empty list if the directory does not exist.
FindFiles
Section titled “FindFiles”static List<string> FindFiles(StringSlice path, StringSlice extension)All files below a directory (recursively) whose name ends with the extension (“.cshift”; empty = all files). The paths start with the given directory and use ‘/’. The result is sorted.