Tag: filecontentresult

找不到文件时处理FileContentResult

我有一个控制器操作,根据容器引用名称(即blob中文件的完整路径名称)从azure blob下载文件。 代码看起来像这样: public FileContentResult GetDocument(String pathName) { try { Byte[] buffer = BlobStorage.DownloadFile(pathName); FileContentResult result = new FileContentResult(buffer, “PDF”); String[] folders = pathName.Split(new char[] { ‘\\’ }, StringSplitOptions.RemoveEmptyEntries); // get the last one as actual “file name” based on some convention result.FileDownloadName = folders[folders.Length – 1]; return result; } catch (Exception ex) { // […]