以下代码有效,但我想知道MemoryStream
创建的是否正确关闭。这应该如何执行或FileStreamResult
为我处理?
public FileStreamResult DownloadBudgetedRoleOpportunities(
Guid projectGuid,
IEnumerable<Guid> guidRequiredRoles)
{
var rolebroker = new ProjectRoleBudgetBroker();
var memstream = rolebroker.CreateBudgetedRoleOpportunies(
projectGuid,
guidRequiredRoles);
var fsr = new FileStreamResult ( memstream, "application/csv" )
{
FileDownloadName = "RoleOpportunities.csv"
};
// memstream.Close(); throws exception
return fsr;
}