title: How do I find out what 'processes' are accessing my Lucene.Net file?
body: <p>I'm getting this exception when running some code to add text to a Lucene.net index:</p>
  
  <blockquote>
    <p>The process cannot access the file
    'E:\SomeProject\SomeProject.Webroot\App_Data\Lucene\segments.new'
    because it is being used by another
    process.</p>
  </blockquote>
  
  <p>What's the easiest way of finding out what the 'other process' is? (I'm running on Win XP) Here's a stripped down code fragment (the exception is being thrown by the 'AddDocument' line after 50+ iterations) in case that's any help:</p>
  
  <pre><code>using l = Lucene.Net;
  
  public void IndexText(List&lt;TextToIndex&gt; textToIndexList)
  {
      l.Analysis.Standard.StandardAnalyzer standardAnalyzer =
          new l.Analysis.Standard.StandardAnalyzer();
      l.Index.IndexWriter indexWriter =
          new l.Index.IndexWriter(_LuceneIndexPath, standardAnalyzer, false);
  
      foreach (TextToIndex textToIndex in textToIndexList)
      {
          l.Documents.Document luceneDoc =
              CreateLuceneDoc(textToIndex.TypeId,
                  textToIndex.TextId,
                  textToIndex.Text,
                  textToIndex.Title,
                  textToIndex.ModifiedDate,
                  textToIndex.CultureCode);
           indexWriter.AddDocument(luceneDoc);
      }
  
      indexWriter.Close();
  }
  </code></pre>