Directory CLASS

A directory (a.k.a. folder), as defined by the underlying file system.

Parent Class

Parent Interfaces

All Members


TypeNameSignature
constructorDirectorypublic Directory(string)
methodcreatepublic bool create()
methoddeletepublic bool delete()
methodexistspublic bool exists()
methodgetChildpublic Item getChild(string)
methodgetNamepublic String getName()
methodgetParentpublic Directory getParent()
methodgetPathpublic String getPath()
methodisFilepublic bool isFile()
methodlistAllpublic Item[] listAll()
methodmovepublic bool move(System.IO.Directory)
methodrenamepublic bool rename(string)
methodsubDirectorypublic Directory subDirectory(string)
methodsubFilepublic File subFile(string)

Constructors


public Directory(string path)

Create a new directory with the specified path.

Parameters

  • path The path to this directory.

Methods


public bool create()

Create a directory represented by this object.

Required Policies

  • System.IO/write

Returns

  • True if the directory was created; false if the directory already exists.

Throws


public bool delete()

Delete this directory recursively.

This operation is not transactional. If an exception is thrown during the call some items may have been deleted.

Required Policies

  • System.IO/write

Returns

  • True if the directory, along with all of its sub-directories and files contained with, were successfully deleted; false if the directory didn't exist.

Throws


public bool exists()

Whether this directory exist on file system.

Required Policies

  • System.IO/stat

Returns

  • True if the directory exists.

public Item getChild(string name)

Get the immediate child with the specified name.

Required Policies

  • System.IO/list

Parameters

  • name The name of the child item.

Returns

Throws

  • System.IO.IOException If the name contains separator. This method cannot be used to get a non-immediate child.

public String getName()

Get the name of this directory. This is only the simple name (with extension part) under the path.

Required Policies

  • System.IO/stat

Returns

  • The name of this directory.

public Directory getParent()

Get the directory this directory resides in.

Required Policies

  • System.IO/stat

Returns

  • The parent directory. Or null if the path doesn't exist.

Throws


public String getPath()

Get the absolute path of this directory, including the name.

Required Policies

  • System.IO/stat

Returns

  • The absolute path of this directory.

public bool isFile()

Return false.

Returns


public Item[] listAll()

List all items directly under this directory.

Required Policies

  • System.IO/list

Returns

  • An array of items directly under this directory, including files and sub-directories. With this method, a recursion-based approach is usually applicable to processing all the items under a given directory.

public bool move(Directory newDir)

(INHERITED DOC)

Move this item to another directory.

Unlike a few file systems where the move command/API serves dual purpose, Julian splits the semantics between move and rename. Rename operation is only for renaming without moving around the file, while this method may only be used to move an item from one directory to another without changing its name. The obvious implication of this division is that for the move operation, the destination must be a valid directory, and there must be no item in that directory that is already possessing the same name. In any of these cases this method returns false. Moving to the same directory is allowed and implemented trivially by returning true directly.

To move an item and change its name, use extension method relocate().

Required Policies

  • System.IO/write

Parameters

  • newDir The new directory.

Returns

  • True if the directory was successfully moved; false if the directory couldn't be.

public bool rename(string newName)

(INHERITED DOC)

Rename this item while remaining in the same directory.

Unlike a few file systems where the move command/API serves dual purpose, Julian splits the semantics between move and rename. Move operation may only be used to move an item from one directory to another without changing its name, while this method is only for renaming without moving around the file. The obvious implication of this division is that for the rename operation, the new name must not contain file system separator, and there must be no item within the same directory that is already possessing the same name. In any of these cases this method returns false.

To move an item and change its name, use extension method relocate().

Required Policies

  • System.IO/write

Parameters

  • newName The new directory name. Must not contain FS separator.

Returns

  • True if the directory was successfully renamed; false if the directory couldn't be.

public Directory subDirectory(string path)

Create a Directory instance representing the child item with the specified path.

The resultant item is merely a handle and may not exist.

Parameters

  • path The path relative to this directory.

Returns

Throws


public File subFile(string path)

Create a File instance representing the child item with the specified path.

The resultant item is merely a handle and may not exist.

Parameters

  • path The path relative to this directory.

Returns

  • A File representing the child item

Throws