让我们假设下载所选文件的控制器:
public FileResult Download( string f ) {
Stream file = MyModel.DownloadFiles( f );
return File( file, "application/octet-stream", (file as FileStream).Name );
}
Run Code Online (Sandbox Code Playgroud)
和MyModel包含
public static Stream DownloadFiles(string file){
return new FileStream(file, FileMode.Open, FileAccess.Read);
}
Run Code Online (Sandbox Code Playgroud)
如果我using在控制器中使用关键字,那么将抛出异常:Cannot access closed file.
好吧,我想确保下载的文件将被处理(我不知道是否可能,如何做到)或不?
谢谢