AzureBlobFileSystem.AzureBlobStorageProvider.RenameFolder C# (CSharp) Method

RenameFolder() public method

public RenameFolder ( string path, string newPath ) : void
path string
newPath string
return void
        public void RenameFolder(string path, string newPath)
        {
            var fullNewPath = newPath;

            EnsurePathIsRelativeAndEnsureContainer(ref path);
            var container = EnsurePathIsRelativeAndEnsureContainer(ref newPath);

            if (path == "")
                throw new ArgumentException("Renaming root folders represented by azure containers is not currently supported", path);

            if (!path.EndsWith("/"))
                path += "/";

            if (!fullNewPath.EndsWith("/"))
                fullNewPath += "/";

            foreach (var blob in container.GetDirectoryReference(path).ListBlobs())
            {
                if (blob is CloudBlockBlob)
                {
                    var azureBlob = new AzureBlobFileStorage((CloudBlockBlob)blob, this);
                    RenameFile(azureBlob.GetPath(), Combine(fullNewPath, azureBlob.GetName()));
                }

                if (blob is CloudBlobDirectory)
                {
                    var azureFolder = new AzureBlobFolderStorage((CloudBlobDirectory)blob, this);
                    RenameFolder(azureFolder.GetPath(), Path.Combine(fullNewPath, azureFolder.GetName()));
                }
            }
        }