Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

ReadWriteFileSystemProvider.Rename Method

Namespace: Rebex.IO.FileSystem
Assembly: Rebex.FileSystem.dll (version 7.0.9147)

Rename(NodeBase, String)

Override this method to implement renaming a DirectoryNode/FileNode.

When the virtual file system is used in the FileServer component, the server session, which contains information about the user and the active connection, can be accessed using Current property.

Declaration
protected abstract NodeBase Rename(NodeBase node, string newName)
Parameters
Type Name Description
NodeBase node

A DirectoryNode or FileNode to be renamed.

String newName

New node name.

Returns
Type Description
NodeBase

Up-to-date instance of FileNode or DirectoryNode which represents the renamed node.

Returned instance should have the Name property set to newName.

Examples
protected override NodeBase Rename(NodeBase node, string newName)
{
 var oldPath = getFullPath(node.Path);
 var newPath = getFullPath(node.Path.ParentPath.AddPathPart(newName));
 if (node.IsDirectory)
 {
   Directory.Move(oldPath, newPath);
   return new DirectoryNode(newName, node.Parent);
 }

 File.Move(oldPath, newPath);
 return new FileNode(newName, node.Parent);

}
In This Article
  • Rename(NodeBase, String)
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies