Skip to main content

AltaFolder

A class in Alta.IO, Alta.Utilities.

A folder on disk that caches its AltaFile and AltaFolder children by name. Creates the directory if it is missing.

Constructors​

MemberWhat it is
AltaFolder(IAltaFolder parent, DirectoryInfo info)Creates an AltaFolder from parent and info.

Fields​

MemberWhat it is
protected Dictionary<string, IAltaFile> filesCache of opened files by name.
protected Dictionary<string, IAltaFolder> subFoldersCache of opened subfolders by name.
1 private and internal field
MemberWhat it is
private static Logger loggerClass logger.

Properties​

MemberWhat it is
IEnumerable<IAltaFile> AllFiles { get; }Every file in the folder except _backup copies. Rescans the disk each time it is read.
IEnumerable<IAltaFolder> AllSubFolders { get; }Every subfolder. Rescans the disk each time it is read.
DirectoryInfo DirectoryInfo { get; }The DirectoryInfo for this folder.
string Name { get; }Folder name.
IAltaFolder Parent { get; }The folder this one was opened from, or null for a root.
string Path { get; }Full path of the folder.

Methods​

MemberWhat it is
virtual void Delete()Unregisters the folder from its parent and deletes it with everything in it. Errors are logged.
virtual Task DeleteAsync()Same as Delete, with the disk work on a background task.
virtual bool FileExists(string name, out IAltaFile file)Returns the file (cached or new) if it exists on disk. Does not create it.
virtual IAltaFile GetFile(string name)Returns the cached file with this name, creating the wrapper if needed. The file does not have to exist yet.
virtual IAltaFolder GetSubfolder(string name)Returns the subfolder with this name, creating it on disk if it is missing.
virtual void RemoveFile(IAltaFile file)Drops a file from the cache. Does not delete it.
void RemoveSubFolder(string name)Drops a subfolder from the cache by name. Does not delete it.
virtual bool SubfolderExists(string name, out IAltaFolder folder)Returns the subfolder if it exists on disk. Does not create it.
virtual void UnloadAllFiles()Queues an unload on every cached file, through all subfolders, then clears both caches.
protected virtual void FindAllFiles()Adds every file on disk except _backup copies to the cache. Used by AllFiles.
protected virtual void FindAllSubFolders()Adds every subdirectory on disk to the cache. Used by AllSubFolders.