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`.
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
It would be nice to have a FilePathResult that opens the file with FileShare.ReadWrite, and the corresponding Controller.File method.
protected internal virtual FilePathResult File(string fileName, string contentType, string fileDownloadName, FileShare share)
{
if (share == FileShare.Read)
{
FilePathResult result = new FilePathResult(fileName, contentType);
result.FileDownloadName = fileDownloadName;
}
else
{
SharedFilePathResult result = new SharedFilePathResult(filename, contentType, share);
result.FileDownloadName = fileDownloadName;
}
return result;
}
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
It would be nice to have a FilePathResult that opens the file with FileShare.ReadWrite, and the corresponding Controller.File method.
protected internal virtual FilePathResult File(string fileName, string contentType, string fileDownloadName, FileShare share)
{
if (share == FileShare.Read)
{
FilePathResult result = new FilePathResult(fileName, contentType);
result.FileDownloadName = fileDownloadName;
}
else
{
SharedFilePathResult result = new SharedFilePathResult(filename, contentType, share);
result.FileDownloadName = fileDownloadName;
}
return result;
}