Let's assume the controller which download selected file:
public FileResult Download( string f ) {
Stream file = MyModel.DownloadFiles( f );
return File( file, "application/octet-stream", (file as FileStream).Name );
}
and MyModel contains
public static Stream DownloadFiles(string file){
return new FileStream(file, FileMode.Open, FileAccess.Read);
}
If I use using
keyword in controller then the exception will be thrown: Cannot access closed file
.
Well, I want to be sure that downloaded file will be disposed (I don't know if is possible, how to do that) or not ?
Thanks