I want to be able to stream application log files to the browser - these files are open for writing, so I need to open them with `FileShare.ReadWrite`. <br /><br />I don't like the idea of opening the file in the Controller and using FileStreamResult, as I'm concerned that there is no guarantee the stream will be disposed - see http://stackoverflow.com/questions/12988704/why-isnt-filestreamresult-and-possibly-actionresult-idisposable<br /><br />It would be nice to have a FilePathResult that opens the file with FileShare.ReadWrite, and the corresponding Controller.File method.<br /><br />protected internal virtual FilePathResult File(string fileName, string contentType, string fileDownloadName, FileShare share)<br />{<br /> if (share == FileShare.Read)<br /> {<br /> FilePathResult result = new FilePathResult(fileName, contentType);<br /> result.FileDownloadName = fileDownloadName;<br /> }<br /> else<br /> {<br /> SharedFilePathResult result = new SharedFilePathResult(filename, contentType, share);<br /> result.FileDownloadName = fileDownloadName;<br /> }<br /> return result;<br />}<br />
↧