title: How can I create a temporary file to cache startup work for a library?
body: <p>I am working on a C# library that performs some expensive computation on startup. I would like to cache this computation so that the cost isn't paid each time the application restarts (think EF and pre-compiled views). </p>
  
  <p>The information I would like to cache is easily writable to a file in text format. Thus, I would like to do the following when the library is invoked:</p>
  
  <ol>
  <li>Generate a unique hash of the configuration parameters.</li>
  <li>Check if there is a cache file for that hash. If so, read it in and use it to skip the setup computation. </li>
  <li>If not, perform the setup computation and generate an appropriate cache file named by a hash of the configuration parameters.</li>
  </ol>
  
  <p>Furthermore, I don't want to permanently litter the users' hard drive such files: I want them to be automatically cleaned up by the operating system (much like temporary files) to the extent that this is possible. </p>
  
  <p>Also, because this is a library I can't depend on other software being installed. Thus, I'd prefer a pure .NET solution.</p>
  
  <p>Can anyone point me to a good method/.NET APIs for doing something like this?</p>