Class CopyDirectory
Copies the content of a directory to a new location preserving file timestamps, symlinks and hard links.
Implements
Inherited Members
Namespace: NanoByte.Common.Storage
Assembly: NanoByte.Common.dll
Syntax
public class CopyDirectory : ReadDirectoryBase, ITask
Constructors
CopyDirectory(String, String)
Creates a new directory copy task.
Declaration
public CopyDirectory(string sourcePath, string destinationPath)
Parameters
Type | Name | Description |
---|---|---|
String | sourcePath | The path of source directory. Must exist! |
String | destinationPath | The path of the target directory. |
Properties
Name
A name describing the task in human-readable form.
Declaration
public override string Name { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
Overwrite
Overwrite existing files and directories at the destination path. This will even replace read-only files!
Declaration
public bool Overwrite { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
UnitsByte
true
if UnitsProcessed and UnitsTotal are measured in bytes;
false
if they are measured in generic units.
Declaration
protected override bool UnitsByte { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Methods
CopyFile(FileInfo, FileInfo)
Copies a single file from one location to another. Can be overridden to modify the copying behavior.
Declaration
protected virtual void CopyFile(FileInfo sourceFile, FileInfo destinationFile)
Parameters
Type | Name | Description |
---|---|---|
FileInfo | sourceFile | |
FileInfo | destinationFile |
Exceptions
Type | Condition |
---|---|
IOException | A problem occurred while copying the file. |
UnauthorizedAccessException | Read access to the |
Execute()
The actual code to be executed.
Declaration
protected override void Execute()
Overrides
Remarks
State is automatically set to Started before calling this method, to Complete after a successful exit and to an appropriate error state in case on an exception. You can set additional TaskStates during execution.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation was canceled. |
IOException | The task ended with IOError. |
WebException | The task ended with WebError. |
HandleDirectory(DirectoryInfo)
Called once for every sub-directory below Source.
Declaration
protected override void HandleDirectory(DirectoryInfo directory)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | directory | The directory to handle. |
Overrides
HandleFile(FileInfo, FileInfo)
Called once for every file below Source.
Declaration
protected override void HandleFile(FileInfo file, FileInfo hardlinkTarget = null)
Parameters
Type | Name | Description |
---|---|---|
FileInfo | file | The file to handle. |
FileInfo | hardlinkTarget | A previously handled file that is hardlinked to |