// </Snippet_MoveDirectory>

        #endregion

        #region Delete a directory

        // ---------------------------------------------------------
        // Delete a directory
        //----------------------------------------------------------

        // <Snippet_DeleteDirectory>
        public void DeleteDirectory(DataLakeFileSystemClient fileSystemClient)
        {
            DataLakeDirectoryClient directoryClient =
                fileSystemClient.GetDirectoryClient("my-directory");

            directoryClient.Delete();
        }
Example #2
0
        /// <summary>
        /// execute command
        /// </summary>
        public override void ExecuteCmdlet()
        {
            IStorageBlobManagement localChannel   = Channel;
            BlobRequestOptions     requestOptions = RequestOptions;

            bool foundAFolder = false;

            DataLakeFileClient      fileClient = null;
            DataLakeDirectoryClient dirClient  = null;

            if (ParameterSetName == ManualParameterSet)
            {
                DataLakeFileSystemClient fileSystem = GetFileSystemClientByName(localChannel, this.FileSystem);
                foundAFolder = GetExistDataLakeGen2Item(fileSystem, this.Path, out fileClient, out dirClient);
            }
            else //BlobParameterSet
            {
                if (!InputObject.IsDirectory)
                {
                    fileClient = InputObject.File;
                }
                else
                {
                    dirClient    = InputObject.Directory;
                    foundAFolder = true;
                }
            }

            if (foundAFolder)
            {
                if (force || ShouldContinue(string.Format("Remove Directory: {0}", GetDataLakeItemUriWithoutSas(dirClient)), ""))
                {
                    dirClient.Delete(true);
                }
            }
            else
            {
                if (force || ShouldContinue(string.Format("Remove File: {0}", GetDataLakeItemUriWithoutSas(fileClient)), ""))
                {
                    fileClient.Delete();
                }
            }

            if (PassThru)
            {
                WriteObject(true);
            }
        }
Example #3
0
        /// <summary>
        /// execute command
        /// </summary>
        public override void ExecuteCmdlet()
        {
            IStorageBlobManagement localChannel = Channel;

            if (ShouldProcess(ParameterSetName == ManualParameterSet ? this.Path : InputObject.Path, "remove"))
            {
                if (ParameterSetName == ManualParameterSet)
                {
                    DataLakeFileSystemClient fileSystem = GetFileSystemClientByName(localChannel, this.FileSystem);
                    DataLakePathClient       pathClient = new DataLakePathClient(fileSystem, this.Path);
                    if (force || ShouldContinue(string.Format("Remove DatalakeGen2 Item: {0}", GetDataLakeItemUriWithoutSas(pathClient)), ""))
                    {
                        pathClient.Delete(true, cancellationToken: this.CmdletCancellationToken);
                    }
                }
                else //ItemPipeline
                {
                    if (!InputObject.IsDirectory)
                    {
                        DataLakeFileClient fileClient = InputObject.File;
                        if (force || ShouldContinue(string.Format("Remove File: {0}", GetDataLakeItemUriWithoutSas(fileClient)), ""))
                        {
                            fileClient.Delete(cancellationToken: this.CmdletCancellationToken);
                        }
                    }
                    else
                    {
                        DataLakeDirectoryClient dirClient = InputObject.Directory;
                        if (force || ShouldContinue(string.Format("Remove Directory: {0}", GetDataLakeItemUriWithoutSas(dirClient)), ""))
                        {
                            dirClient.Delete(true, cancellationToken: this.CmdletCancellationToken);
                        }
                    }
                }

                if (PassThru)
                {
                    WriteObject(true);
                }
            }
        }
Example #4
0
        public void Delete(string path, bool recursive)
        {
            DataLakeDirectoryClient directoryClient = GetDirectoryClient(path);

            directoryClient.Delete(recursive);
        }