Items can be deleted using the Delete method. With the Xceed FileSystem, a folder is a folder regardless of if it is located on a local disk, in a zip file, in memory, or on an FTP server.
The following example demonstrates how to delete a file on a local drive using the steps listed below:
Create an instance of a DiskFile which will represent the file on the local drive to delete.
Verify if the file exists prior to deleting it using the Exists property. If an attempt is made to delete a file that does not exist, an exception will be thrown.
Delete the file by calling its Delete method
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
All methods exposed by the Xceed FileSystem's FileSystemItem, AbstractFolder, AbstractFile, and derived classes have an overload that can be used when events are required. Events can be handled by creating an instance of the FileSystemEvents class and subscribing to the desired events. For example:
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
using Xceed.FileSystem; |
Do you want to display progress information? Create an instance of the FileSystemEvents class and handle the ByteProgression and/or ItemProgression events.
Do you want to display progress information when a folder is being scanned? Create an instance of the FileSystemEvents class and handle the ScanningFolder event.
Do you want to intervene when an error occurs with one or more of the items being manipulated? Create an instance of the FileSystemEvents class and handle the ItemException event.