Example #1
0
        /// <summary>
        /// Copy the directory
        /// </summary>
        /// <param name="sourcePath">Path to the source directory</param>
        /// <param name="destinationPath">Path to the destination directory</param>
        /// <returns>A task that represents the completion of the operation</returns>
        protected virtual async Task CopyDirectoryAsync(string sourcePath, string destinationPath)
        {
            string directoryPath = GetFullPath(GetVirtualPath(sourcePath));

            if (!_fileProvider.DirectoryExists(directoryPath))
            {
                throw new Exception(GetLanguageResource("E_CopyDirInvalidPath"));
            }

            string newDirectoryPath = GetFullPath(GetVirtualPath($"{destinationPath.TrimEnd('/')}/{_fileProvider.GetDirectoryName(directoryPath)}"));

            if (_fileProvider.DirectoryExists(newDirectoryPath))
            {
                throw new Exception(GetLanguageResource("E_DirAlreadyExists"));
            }

            CopyDirectory(directoryPath, newDirectoryPath);

            await HttpContext.Response.WriteAsync(GetSuccessResponse());
        }