Items can be copied or moved from one location to another using the CopyTo, CopyFilesTo, MoveTo, or MoveFilesTo methods. 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 copy files from one local folder to another using the steps listed below:
Create an instance of a DiskFolder which will represent the source folder from which to retrieve the files.
Create an instance of a DiskFolder which will represent the destination folder where the files will be copied to.
Call the source folder's CopyFilesTo method to copy the files to the destination folder.
VB.NET | Copy Code |
---|---|
Dim source As New DiskFolder( "c:\source" ) source.CopyFilesTo( destination, True, True ) |
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 |
---|---|
|
Do you want to filter (specify specific files and folders) the items that are to be copied? Use filters.
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.