一旦使用完毕,是否应该关闭HttpPostedFile.Inputstream? [英] Should we close HttpPostedFile.Inputstream, once we are done using it?
问题描述
我正在上传文件,并将Inputstream直接馈送到我的一个对象.我的问题是,一旦完成处理,是否应该关闭并刷新它?
I am uploading a file and directly feeding Inputstream to one of my objects. My Question is should we close and flush it once we are done processing it?
推荐答案
您不需要 显式关闭它,当请求结束时,将分配服务器上分配的资源.请参阅MSDN文档中的最后说明.
You don't need to explicitly close it, the resources allocated on your server are disposed when the request ends. See the final remark in the MSDN docs.
http://msdn.microsoft.com/zh-我们/library/system.web.httppostedfile.aspx
但是,如果问题是应该,则您将其关闭(或至少将其丢弃)-那么我会说是的.为什么不?它可以比其他方式更早地释放资源,并且您知道您不再需要它们.
However if the question is should you close it (or at least dispose of it) - then I'd say yes. Why not? It may release resources earlier than they would otherwise be released and you know you don't need them any more.
这篇关于一旦使用完毕,是否应该关闭HttpPostedFile.Inputstream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!