The AbstractFolder class, as well as all the classes that derive from the AbstractFolder class, can be derived from to create custom folder classes.
Basic Steps
When creating a class that derives from the AbstractFolder class or one of its derived classes, the following functions must be implemented:
Method/Property | Description |
---|---|
DoGetChildItems | Retrieves an array of FileSystemItem objects representing the child items of the folder. |
DoGetFile | Retrieves a reference to an AbstractFile object contained within the folder. |
DoGetFolder | Retrieves a reference to an AbstractFolder object contained within the folder. |
DoName | Gets or sets the short name of the item. |
DoFullName | Gets the full name of the item, including path. |
DoAttributes | Gets or sets the attributes of the item. If your custom folder does not support attributes, override the DoHasAttributes property and return false. This will prevent the DoAttributes method from being called needlessly. |
DoCreationDateTime | Gets or sets the creation date and time of the item. If your custom folder does not support having a creation date and time, override the DoHasCreationDateTime property and return false. This will prevent the DoCreationDateTime method from being called needlessly. |
DoLastWriteDateTime | Gets or sets the modification date and time of the item. If your custom folder does not support having a last write date and time, override the DoHasLastWriteDateTime property and return false. This will prevent the DoLastWriteDateTime method from being called needlessly. |
DoLastAccessDateTime | Gets or sets the last access date and time of the item. If your custom folder does not support having a last access date and time, override the DoHasLastAccessDateTime property and return false. This will prevent the DoLastAccessDateTime method from being called needlessly. |
DoParentFolder | Gets a reference to the parent folder of this item. |
DoRootFolder | Gets a reference to the root folder of this item. |
DoExists | Gets a boolean value indicating if the item physically exists. |
DoRefresh | Re-reads the information from the physical item. |
DoCreate | Creates the physical item represented by the FileSystemItem object. |
DoDelete | Permanently deletes the physical item. |
IsSameAs | Gets a boolean value indicating if the source and target items are the same. |
IsPathRooted | Returns a boolean value indicating if the path passed is rooted in the environment of the FileSystemItem object we are dealing with. |
Each of the overridden abstract "Do" methods and properties are called by their corresponding public counterparts and are responsible for executing the actual operation. The public method simply validates the parameters. It is the "Do" implementation that must make sure that the required conditions are met. For example, in order to call delete on an item, it must first exist. This means that your implementation of DoDelete must throw an ItemDoesNotExistException if the item does not exist.
Template
The following example demonstrates the minimum implementation required for a class that derives from the AbstractFile class.
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|