I've got some code like this:
public async Task<IEnumerable<Response>> SaveFiles(IEnumerable<string> filePaths)
{
    var baseFolder = "C:\\Temp";
    var fullTempPath = $"{baseFolder}\\{Guid.NewGuid()}";
    var fileDirectory = Directory.CreateDirectory(fullTempPath);
    Task<Response>[] tasks = new Task<Response>[filePaths.Count()];
    for (int i = 0; i < filePaths.Count(); i++)
    {
        var blobClientDetails = GetBlobClientDetails(filePaths.ElementAt(i));
        var credentials = new AzureSasCredential(blobClientDetails.Value);
        var blob = new BlobClient(blobClientDetails.Key, credentials);
        tasks[i] = blob.DownloadToAsync(fileDirectory.FullName);
    }
    return await Task.WhenAll(tasks);
}
private KeyValuePair<Uri, string> GetBlobClientDetails(string filePath)
{
    var filePathExcludingSAS = filePath.Substring(0, filePath.IndexOf('?'));
    var sasToken = filePath.Substring(filePath.IndexOf('?') + 1);
    return new KeyValuePair<Uri, string>(new Uri(filePathExcludingSAS), sasToken);
}
The theory is that this will trigger the download of each file before waiting for the download of the previous one to complete, hence the Task.WhenAll(tasks) at the end. However, I want to be able to accurately catch an exception and be able to specify which file failed to download. How can I do that?
 
    