public override Task <DexihFiles> GetFileEnumerator(FlatFile file, EFlatFilePath path, string searchPattern) { try { var files = new List <DexihFileProperties>(); var fullDirectory = GetFullPath(file, path); var filenames = string.IsNullOrEmpty(searchPattern) ? Directory.GetFiles(fullDirectory) : Directory.GetFiles(fullDirectory, searchPattern); foreach (var fileName in filenames) { var fileInfo = new FileInfo(fileName); files.Add(new DexihFileProperties() { FileName = fileInfo.Name, LastModified = fileInfo.LastWriteTime, Length = fileInfo.Length }); } var newFiles = new DexihFiles(files.ToArray()); return(Task.FromResult(newFiles)); } catch (Exception ex) { throw new ConnectionException($"Error occurred getting files from {path} with pattern {searchPattern}. {ex.Message}", ex); } }
public override Task <DexihFiles> GetFileEnumerator(FlatFile file, EFlatFilePath path, string searchPattern) { try { var files = new List <DexihFileProperties>(); using (var client = GetSftpClient()) { var fullDirectory = GetFullPath(file, path); var directoryListing = client.ListDirectory(fullDirectory); foreach (var directoryItem in directoryListing) { if (directoryItem.IsRegularFile && (string.IsNullOrEmpty(searchPattern) || FitsMask(directoryItem.Name, searchPattern))) { files.Add(new DexihFileProperties() { FileName = directoryItem.Name, LastModified = directoryItem.LastWriteTime, Length = directoryItem.Length }); } } var newFiles = new DexihFiles(files.ToArray()); return(Task.FromResult(newFiles)); } } catch (Exception ex) { throw new ConnectionException($"Error occurred getting files from {path} with pattern {searchPattern}. {ex.Message}", ex); } }
public override async Task <DexihFiles> GetFileEnumerator(FlatFile file, EFlatFilePath path, string searchPattern) { try { var files = new List <DexihFileProperties>(); using (var client = await GetFtpClient()) { var fullDirectory = GetFullPath(file, path); var directoryListing = await client.GetListingAsync(fullDirectory); foreach (var directoryItem in directoryListing) { if (directoryItem.Type == FtpFileSystemObjectType.File && (string.IsNullOrEmpty(searchPattern) || FitsMask(directoryItem.Name, searchPattern))) { files.Add(new DexihFileProperties() { FileName = directoryItem.Name, LastModified = directoryItem.Modified, Length = directoryItem.Size }); } } var newFiles = new DexihFiles(files.ToArray()); return(newFiles); } } catch (Exception ex) { throw new ConnectionException($"Error occurred getting files from {path} with pattern {searchPattern}. {ex.Message}", ex); } }
public override async Task <DexihFiles> GetFileEnumerator(FlatFile file, EFlatFilePath path, string searchPattern) { try { var files = new List <DexihFileProperties>(); var cloudFileDirectory = await GetFileDirectory(file); var pathstring = file.GetPath(path); var pathlength = pathstring.Length + 1; var cloudSubDirectory = cloudFileDirectory.GetDirectoryReference(pathstring); BlobContinuationToken continuationToken = null; var list = new List <IListBlobItem>(); do { var filesList = await cloudSubDirectory.ListBlobsSegmentedAsync(false, BlobListingDetails.None, 500, continuationToken, null, null); continuationToken = filesList.ContinuationToken; list.AddRange(filesList.Results); } while (continuationToken != null); foreach (CloudBlob cloudFile in list) { await cloudFile.FetchAttributesAsync(); var fileName = cloudFile.Name.Substring(pathlength); if (string.IsNullOrEmpty(searchPattern) || FitsMask(file.Name, searchPattern)) { files.Add(new DexihFileProperties() { FileName = fileName, LastModified = cloudFile.Properties.LastModified.Value.DateTime, Length = cloudFile.Properties.Length }); } } var newFiles = new DexihFiles(files.ToArray()); return(newFiles); } catch (Exception ex) { throw new ConnectionException($"Failed get file {file.Name} files in path {path} with pattern {searchPattern}. {ex.Message}", ex); } }