QuickOPC User's Guide and Reference
MoveTo Method (IWritableDirectoryContents)



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.Extensions.FileProviders Namespace > IWritableDirectoryContents Interface : MoveTo Method
The name and path to which to move this directory. The destination cannot be a directory with the identical name. It can be an existing directory to which you want to add this directory as a subdirectory.
Moves a directory and its contents to a new path.
Syntax
'Declaration
 
Sub MoveTo( _
   ByVal destinationDirectoryPath As String _
) 
'Usage
 
Dim instance As IWritableDirectoryContents
Dim destinationDirectoryPath As String
 
instance.MoveTo(destinationDirectoryPath)

Parameters

destinationDirectoryPath
The name and path to which to move this directory. The destination cannot be a directory with the identical name. It can be an existing directory to which you want to add this directory as a subdirectory.
Exceptions
ExceptionDescription

One of the arguments provided to a method is not valid.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Part of a file or directory cannot be found.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

An I/O error has occurred.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

An invoked method is not supported at all, or is not supported with the parameters used to create the object.

A security error was detected.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Remarks

This method is similar in purpose to System.IO.DirectoryInfo.MoveTo(System.String), but is generalized for any kind of writable directory contents, not just files in the physical file system.

You can use this method to rename a directory, keeping it in the same parent directory, too. You need to specify an absolute path in this case (or a relative path that uses navigation above the root). It is recommended to use the IWritableDirectoryContentsExtension.Rename method if your intent is renaming and not moving. The IWritableDirectoryContentsExtension.Rename has additional checks that guarantee that renaming and not moving will occur.

For Microsoft.Extensions.FileProviders.IDirectoryContents, IDirectory2, IDirectoryContents2, IWritableDirectory and IWritableDirectoryContents, relative paths are based on the directory itself; absolute paths are based on the root directory of the file provider. Notice the difference from Microsoft.Extensions.FileProviders.IFileInfo, IFileInfo2 and IWritableFileInfo, where relative paths are based on the directory where the file is located.

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also