public virtual Task <FileSystemDto> UpdateAsync([Required, StringLength(255)] string name, FileSystemUpdateDto input)
        {
            string fileSystemPath = GetFileSystemPath(name);
            var    renameFilePath = GetFileSystemPath(input.NewName);

            if (File.Exists(fileSystemPath))
            {
                if (File.Exists(renameFilePath))
                {
                    throw new UserFriendlyException(L["FilePathAlreadyExists"]);
                }
                File.Move(fileSystemPath, renameFilePath);

                var fileInfo   = new FileInfo(renameFilePath);
                var fileSystem = new FileSystemDto
                {
                    Type                 = FileSystemType.File,
                    Name                 = fileInfo.Name,
                    Size                 = fileInfo.Length,
                    Extension            = fileInfo.Extension,
                    CreationTime         = fileInfo.CreationTime,
                    LastModificationTime = fileInfo.LastWriteTime
                };
                if (fileInfo.Directory != null && !fileInfo.Directory.FullName.IsNullOrWhiteSpace())
                {
                    fileSystem.Parent = GetFileSystemRelativePath(fileInfo.Directory.FullName);
                }
                return(Task.FromResult(fileSystem));
            }
            if (Directory.Exists(fileSystemPath))
            {
                if (Directory.Exists(renameFilePath))
                {
                    throw new UserFriendlyException(L["FilePathAlreadyExists"]);
                }

                Directory.Move(fileSystemPath, renameFilePath);

                var directoryInfo = new DirectoryInfo(renameFilePath);
                var fileSystem    = new FileSystemDto
                {
                    Type                 = FileSystemType.Folder,
                    Name                 = directoryInfo.Name,
                    CreationTime         = directoryInfo.CreationTime,
                    LastModificationTime = directoryInfo.LastWriteTime
                };
                if (directoryInfo.Parent != null && !directoryInfo.Parent.FullName.IsNullOrWhiteSpace())
                {
                    fileSystem.Parent = GetFileSystemRelativePath(directoryInfo.Parent.FullName);
                }
                return(Task.FromResult(fileSystem));
            }
            throw new UserFriendlyException(L["FilePathNotFound"]);
        }
        public virtual Task <FileSystemDto> GetAsync(FileSystemGetDto input)
        {
            var fileSystemPath = GetFileSystemPath(input.Path);

            fileSystemPath = Path.Combine(fileSystemPath, input.Name);
            if (File.Exists(fileSystemPath))
            {
                var fileInfo   = new FileInfo(fileSystemPath);
                var fileSystem = new FileSystemDto
                {
                    Type                 = FileSystemType.File,
                    Name                 = fileInfo.Name,
                    Size                 = fileInfo.Length,
                    Extension            = fileInfo.Extension,
                    CreationTime         = fileInfo.CreationTime,
                    LastModificationTime = fileInfo.LastWriteTime
                };
                if (fileInfo.Directory != null && !fileInfo.Directory.FullName.IsNullOrWhiteSpace())
                {
                    fileSystem.Parent = GetFileSystemRelativePath(fileInfo.Directory.FullName);
                }
                return(Task.FromResult(fileSystem));
            }
            if (Directory.Exists(fileSystemPath))
            {
                var directoryInfo = new DirectoryInfo(fileSystemPath);
                var fileSystem    = new FileSystemDto
                {
                    Type                 = FileSystemType.Folder,
                    Name                 = directoryInfo.Name,
                    CreationTime         = directoryInfo.CreationTime,
                    LastModificationTime = directoryInfo.LastWriteTime
                };
                if (directoryInfo.Parent != null && !directoryInfo.Parent.FullName.IsNullOrWhiteSpace())
                {
                    fileSystem.Parent = GetFileSystemRelativePath(directoryInfo.Parent.FullName);
                }
                return(Task.FromResult(fileSystem));
            }
            throw new UserFriendlyException(L["FilePathNotFound"]);
        }
        public virtual Task <PagedResultDto <FileSystemDto> > GetListAsync(GetFileSystemListDto input)
        {
            List <FileSystemDto> fileSystems = new List <FileSystemDto>();

            string fileSystemPath = GetFileSystemBashPath();

            if (!input.Parent.IsNullOrWhiteSpace())
            {
                fileSystemPath = GetFileSystemPath(input.Parent);
            }
            var directoryInfo = new DirectoryInfo(fileSystemPath);

            if (!directoryInfo.Exists)
            {
                return(Task.FromResult(new PagedResultDto <FileSystemDto>(0, fileSystems)));
            }
            // 查询全部文件系统
            var fileSystemInfos = directoryInfo.GetFileSystemInfos();

            // 指定搜索条件查询目录
            FileSystemInfo[] fileSystemInfoSearchChildren;
            if (!input.Filter.IsNullOrWhiteSpace())
            {
                var searchPattern = $"*{input.Filter}*";
                fileSystemInfoSearchChildren = directoryInfo.GetFileSystemInfos(searchPattern);
            }
            else
            {
                fileSystemInfoSearchChildren = directoryInfo.GetFileSystemInfos();
            }

            fileSystemInfoSearchChildren = fileSystemInfoSearchChildren
                                           .Skip((input.SkipCount - 1) * input.MaxResultCount)
                                           .Take(input.MaxResultCount)
                                           .ToArray();

            foreach (var fileSystemInfo in fileSystemInfoSearchChildren)
            {
                var fileSystem = new FileSystemDto
                {
                    Name                 = fileSystemInfo.Name,
                    CreationTime         = fileSystemInfo.CreationTime,
                    LastModificationTime = fileSystemInfo.LastWriteTime,
                };

                if (fileSystemInfo is FileInfo fileInfo)
                {
                    fileSystem.Type      = FileSystemType.File;
                    fileSystem.Size      = fileInfo.Length;
                    fileSystem.Extension = fileInfo.Extension;
                    if (fileInfo.Directory != null && !fileInfo.Directory.FullName.IsNullOrWhiteSpace())
                    {
                        fileSystem.Parent = GetFileSystemRelativePath(fileInfo.Directory.FullName);
                    }
                }
                else if (fileSystemInfo is DirectoryInfo directory)
                {
                    fileSystem.Type = FileSystemType.Folder;
                    if (directory.Parent != null && !directory.Parent.FullName.IsNullOrWhiteSpace())
                    {
                        fileSystem.Parent = GetFileSystemRelativePath(directory.Parent.FullName);
                    }
                }
                fileSystems.Add(fileSystem);
            }

            fileSystems = fileSystems
                          .OrderBy(f => f.Type)
                          .ThenBy(f => f.Name)
                          .ToList();

            return(Task.FromResult(new PagedResultDto <FileSystemDto>(
                                       fileSystemInfos.Length, fileSystems
                                       )));
        }