I would like to know behavior for method File.ReadAllText Here an example of my code:
uxJavaScriptTinyMCEDisplayer.Text = File.ReadAllText(Server.MapPath("TinyMCEJava开发者_高级运维ScriptAdmin.txt"));
File.ReadAllText have some CACHE behavior? So taht the first time the file is read, will be kept in memory and not re-read again?
thanks
There is no direct caching in .Net, however, you get caching behaviour indirectly via the OS.
Windows is very much optimized to cache file contents in memory and has a layer that facilitates in-memory caching of file system contents. But as Frédéric points out in his comment, you should not rely on this behaviour as memory pressure, cache ageing, etc, may mean that cached content is dropped.
The OS does a good job of caching if there is plenty of memory.
Update
This is an old article (Win2K) but gives some idea as to OS disk caching.
http://technet.microsoft.com/en-us/library/bb742613.aspx
No cache. It will read the current contents of the file at the given path.
精彩评论