title: Compare filenames with already existing(attached) databases on server
body: <p>I need to compare filenames(.mdf) with existing databases on SQL server, but I don't know how. The databases that are not attached must show in datagridview. </p>
  
  <p>Here is the code so far:</p>
  
  <pre><code>private void loadDB_Click_1(object sender, EventArgs e)
  {
      String[] files = Directory.GetFiles(@"C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\", "*.mdf", SearchOption.AllDirectories);
  
      DataTable table = new DataTable();
      table.Columns.Add("File Name");
      table.Columns.Add("Path");
  
      for (int i = 0; i &lt; files.Length; i++)
      {
          FileInfo file = new FileInfo(files[i]);
          table.Rows.Add((Path.GetFileNameWithoutExtension(file.Name)),Path.GetFullPath(file.Name));
      }     
  
      dataGridView2.DataSource = table;
  }
  </code></pre>