public virtual async Task <string[]> ListFiles(string path) { try { if (Directory.Exists(path)) { DirectoryInfo info = new DirectoryInfo(path); FileInfo[] finfo = info.GetFiles(); List <string> list = new List <string>(); foreach (var item in finfo) { list.Add(item.Name); } //return await Task.FromResult<string[]>(Directory.GetFiles(path)); if (list.Count > 0) { return(await Task.FromResult <string[]>(list.ToArray <string>())); } else { return(null); } } else { return(null); } } catch (Exception ex) { operations.LogToDocker("ListFiles", ex); throw ex; } }
public virtual async Task <string[]> ListFiles(string path) { try { if (Directory.Exists(path)) { return(await Task.FromResult <string[]>(Directory.GetFiles(path))); } else { return(null); } } catch (Exception ex) { operations.LogToDocker("ListFiles", ex); throw ex; } }
public async Task DownloadFile(string path, string filename, string blobPath, string blobFilename, bool append = false, CancellationToken token = default(CancellationToken)) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } if (string.IsNullOrEmpty(filename)) { throw new ArgumentNullException("filename"); } if (string.IsNullOrEmpty(blobPath)) { throw new ArgumentNullException("blobPath"); } if (string.IsNullOrEmpty(blobFilename)) { throw new ArgumentNullException("blobFilename"); } try { string fileToWrite = operations.FixPath(path) + filename; string container = operations.GetContainerName(blobPath); string fileToRead = operations.GetFilenameForContainer(blobPath, blobFilename); byte[] blob = await operations.ReadBlockBlobAsync(container, fileToRead, token); if (!token.IsCancellationRequested) { if (append) { await operations.WriteAppendFileAsync(fileToWrite, blob); } else { await operations.WriteFileAsync(fileToWrite, blob); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); operations.LogToDocker("DownloadFile", ex); throw ex; } }