User283571144 posted
Hi slkim,
According to your description, I suggest you could use WindowsAzure.Storage library to help you download the file from Azure File share.
You could use CloudFile.DownloadToStreamAsync method to download the file and return the view.
More details, you could refer to below codes:
View:
<a href="/home/GetFileFromFileshare/1">Click to get file</a>
Controller:
public ActionResult GetFileFromFileshare(string id)
{
MemoryStream ms = new MemoryStream();
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=fehanteststorage;AccountKey=os6wlWkQoQYUQUCZGDcSUBXzIl+u5S8IXSGxaYTQuo5Ueh2ppexIvt096j1IyRTJazqqRgrTkdaB6VtCSthE3A==;EndpointSuffix=core.windows.net");
// Create a CloudFileClient object for credentialed access to Azure Files.
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
// Get a reference to the file share we created previously.
CloudFileShare share = fileClient.GetShareReference("botfunctest");
// Ensure that the share exists.
if (share.Exists())
{
// Get a reference to the root directory for the share.
CloudFileDirectory rootDir = share.GetRootDirectoryReference();
// Get a reference to the directory we created previously.
CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("data");
// Ensure that the directory exists.
if (sampleDir.Exists())
{
// Get a reference to the file we created previously.
CloudFile file = sampleDir.GetFileReference("17.gif");
// Ensure that the file exists.
if (file.Exists())
{
// Write the contents of the file to the console window.
file.DownloadToStreamAsync(ms);
Stream blobStream = file.OpenReadAsync().Result;
return File(blobStream, file.Properties.ContentType, file.Name);
}
else
{
return Content("File does not exist");
}
}
else
{
return Content("Dir does not exist");
}
}
else
{
return Content("File does not exist");
}
}
Result:

Best Regards,
Brando