Ejemplo n.º 1
0
        protected override void RenameItem(string path, string newName)
        {
            object obj = FindItemByPath(Utilities.NormalizePath(path), true, false);

            DiscFileSystemInfo fsiObj = obj as DiscFileSystemInfo;

            if (fsiObj == null)
            {
                WriteError(new ErrorRecord(
                               new InvalidOperationException("Cannot move items to this location"),
                               "BadParentForNewItem",
                               ErrorCategory.InvalidArgument,
                               newName));
                return;
            }

            string newFullName = Path.Combine(Path.GetDirectoryName(fsiObj.FullName.TrimEnd('\\')), newName);

            if (obj is DiscDirectoryInfo)
            {
                DiscDirectoryInfo dirObj = (DiscDirectoryInfo)obj;
                dirObj.MoveTo(newFullName);
            }
            else
            {
                DiscFileInfo fileObj = (DiscFileInfo)obj;
                fileObj.MoveTo(newFullName);
            }
        }