title: Using memory mapped file to compensate for out of memory in C#
body: <p>I have a problem - previously I was after an algorithm to solve a part of it (see <em><a href="https://stackoverflow.com/questions/9804683/combine-linq-queries/9804942#9804942">Combine LINQ queries</a></em>) anyway, and I have come to a huge issue.</p>
  
  <p>At around 540k directories, it's crashing out with out of memory. :(</p>
  
  <p>I am trying to process and store the company SAN file information, and we need to do this, because we have people who keep data for 25 years and they don't need to, but it's hard to track. It's a total of up to 70&nbsp;TB of files. So, as you can imagine, it's a lot of files.</p>
  
  <p>From what I've read however, memory mapped files can't be dynamic? Is this true? I can't know prior how many files + directories there are for sure.</p>
  
  <p>If not, (please say not), can someone do me a short example on how to make a dynamic mapped file (code provided in the <em><a href="https://stackoverflow.com/questions/9804683/combine-linq-queries/9804942#9804942">Combine LINQ queries</a></em> question). In short, I create a directory structure in memory holding directory → directories + files(name, size, access date, modified date, and creation date).</p>
  
  <p>Any clues would be appreciated as this would get around my problem if it's possible.</p>