title: C# exception for accessing same resources two times
body: <p>Using Windows Forms and calling the WordNet API in a button click handler:</p>
  
  <pre><code>frmWordnetAPI relatedWords = new frmWordnetAPI ();
          relatedWords.ShowDialog();
  </code></pre>
  
  <p>this API is getting some data from the source file directory. </p>
  
  <p>When compiling the program, on the first button click the form is loading perfectly, but when I close the API and click the button again to load it is throwing an exception saying: </p>
  
  <pre><code>The process cannot access the file 'D:\MIT\project\wordnet API\TestApplication\WNdb-3.0\dict\index.adj' because it is being used by another process.
  </code></pre>
  
  <p>The following code is throwing an exception:</p>
  
  <pre><code>BinarySearchTextStream searchStream = new BinarySearchTextStream(indexPath, new BinarySearchTextStream.SearchComparisonDelegate(delegate(string searchWord, string currentLine)
                          {
                              // if we landed on the header text, search further down
                              if (currentLine[0] == ' ')
                                  return 1;
  
                              string currentWord = currentLine.Substring(0, currentLine.IndexOf(' '));
                              return searchWord.CompareTo(currentWord);
  
                          }));
  </code></pre>
  
  <p>Please help!</p>