public virtual async Task <StorageReturnValue> DownloadFileAsynch(string downloadToLocation, List <string> fileNameWithExtList) { result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null); List <FileStorageAttachment> listFileDownload = new List <FileStorageAttachment>(); foreach (var item in fileNameWithExtList) { string pathFileName = Path.Combine(downloadToLocation, item.Trim()); FileStorageAttachment downloaded = null; result = await fileManagementAsync.CreateFileDownloadAsync(pathFileName); if (result.IsSuccess) { downloaded = (FileStorageAttachment)result.ListFile[0]; result.IsSuccess = true; result.ListFile.Add(downloaded); } else { result.ErrorMessage = FileStorageProperties.GetInstance.WrongFileDownload; } } return(result); }
public virtual StorageReturnValue CreateFileDownload(string pathFileNameWithExt) { result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null); try { Byte[] mybyte = null; var myblob = azure.blobContainerInstance.GetBlockBlobReference(pathFileNameWithExt); myblob.DownloadToByteArrayAsync(mybyte, 0).GetAwaiter().GetResult(); FileStorageAttachment fileStorage = new FileStorageAttachment(); fileStorage.FileAttachment = mybyte; fileStorage.FileNameWithExt = pathFileNameWithExt; fileStorage.FileNameWithExtRenamed = pathFileNameWithExt; var file = new List <FileStorageAttachment>(); file.Add(fileStorage); result = new StorageReturnValue(true, string.Empty, file); } catch (Exception ex) { result = new StorageReturnValue(false, ex.Message + " :" + FileStorageProperties.GetInstance.WrongFileUpload, null); } return(result); }