Esempio n. 1
0
        public Task <IRemoteFolder> GetFolder(string path)
        {
            path = GetPath(path);

            DirectoryInfo directory = new DirectoryInfo(path);

            if (!directory.Exists)
            {
                return(Task.FromResult <IRemoteFolder>(null));
            }

            RemoteFolder folder = new RemoteFolder(path, PathSeparator, _settings.RootPath);

            foreach (DirectoryInfo subDirectory in directory.GetDirectories())
            {
                folder.AddFolder(subDirectory.Name);
            }

            foreach (FileInfo file in directory.GetFiles())
            {
                folder.AddFile(file.Name, file.LastWriteTime);
            }

            return(Task.FromResult <IRemoteFolder>(folder));
        }
Esempio n. 2
0
        public async Task <IRemoteFolder> GetFolder(string path)
        {
            RemoteFolder folder = new RemoteFolder(path, PathSeparator);

            FtpListItem[] list = await _client.Value.GetListingAsync(path);

            foreach (FtpListItem listItem in list)
            {
                if (listItem.Type == FtpFileSystemObjectType.Directory)
                {
                    folder.AddFolder(listItem.Name);
                }
                else
                {
                    folder.AddFile(listItem.Name, listItem.Modified);
                }
            }

            return(folder);
        }
Esempio n. 3
0
        public async Task <IRemoteFolder> GetFolder(string path)
        {
            string            url      = $"{FileSystemEndpoints.FolderEndpoint}?path={path}";
            FolderApiResponse response = await GetResponse <FolderApiResponse>(url);

            if (response == null)
            {
                return(null);
            }

            RemoteFolder folder = new RemoteFolder(response.Path, PathSeparator);

            foreach (SubFolderApiResponse subFolder in response.Folders)
            {
                folder.AddFolder(subFolder.Name);
            }

            foreach (FileApiResponse file in response.Files)
            {
                folder.AddFile(file.Name, file.LastModified);
            }

            return(folder);
        }