title: How do I delete a Lucene index without affecting other non-index files in the directory?
body: <p>I am wanting to write back an in-memory Lucene index to disk, overtop of the originally-loaded index. Currently if I call <code>Directory.Copy( _ramDirectory, _fileSystemDirectory, false )</code>, it simply adds the new files to the directory but leaves the old (stale) ones there.</p>
  
  <p>I tried calling:</p>
  
  <pre><code>new IndexWriter( _fsd, _analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED ).Close();
  </code></pre>
  
  <p>...(to create a new empty index in the directory) but this has strange behavior and sometimes results in the entire index being wiped clean on the next run of the program.</p>
  
  <p>Is there any way I can simply get a list of the files a file system index is currently using so I can delete them manually? I don't want to blindly erase all files in the directory in case there are some non-index files there.</p>
  
  <p>Apparently <code>FSDirectory.ListAll()</code> lists all files in the physical directory, whether or not they are actually part of the index. Is there any way I can tell if a particular file is used/created by the index? I mean I can't even check file extensions due to Lucene's bizarre file naming conventions.</p>