开发者

ASP.NET Retrieving text via System.IO.File vs WebRequest

I have a text file that I need to retrieve to populate a web page. My first instinct was to use System.IO.File to open and read the file contents.

then it occured to me I could also use a web request (since the file lives on the webserver). I'm wondering which one is a better choice.

开发者_运维问答

I figure using the file system would be faster, since I would imagine that eventually, the webrequest has to access the file anyway...

using the file system is easier to code as well, since all I have to do is open the file and read its contents.

any thoughts?

thanks!


I assume you are talking about the server-side code of an ASP.NET app, e.g. the code-behind of a page. In that case, the text file is local to your code/application (it's located on the same computer) and you should therefore use System.IO.File to read it. Using a web request would definitely be less effective.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜