Ejemplo n.º 1
0
        public override bool MoveResource(IStorageProviderSession session, ICloudFileSystemEntry fsentry, ICloudDirectoryEntry newParent)
        {
            // get credentials
            ICredentials creds = ((GenericNetworkCredentials)session.SessionToken).GetCredential(null, null);

            // get old name uri
            String uriPath = GetResourceUrl(session, fsentry.Parent, fsentry.Name);

            // get the new path
            String TargetPath = PathHelper.Combine(GenericHelper.GetResourcePath(newParent), fsentry.Name);

            // do it
            if (!_ftpService.FtpRename(uriPath, TargetPath, creds))
            {
                return(false);
            }

            // remove from parent
            (fsentry.Parent as BaseDirectoryEntry).RemoveChild(fsentry as BaseFileEntry);

            // add to new parent
            (newParent as BaseDirectoryEntry).AddChild(fsentry as BaseFileEntry);

            return(true);
        }