List<string> storedFileList = new List<string>();
storedFileList.AddRange(new string[] {"a.txt", "b.csv", "c.png"});
DataTable storedFiles = new DataTable();
storedFiles.Columns.Add(new DataColumn("filename", typeof(string)));
foreach (string name in storedFileList)
{
storedFiles.LoadDataRow(new object[] {name}, true);
}
var qryAlreadyStored = from DataRow r in storedFiles.Rows
select r["filename"];
string path = @"C:\TheDirectory\PathThat\WeAre\InterestedIn";
DirectoryInfo dir = new DirectoryInfo(path);
var qryFile = from FileInfo file in dir.GetFiles()
where !qryAlreadyStored.ToList().Contains(file.Name)
orderby file.Name ascending
select file.Name;
DataTable filesToDisplay = storedFiles.Clone();
foreach (string newName in qryFile)
{
filesToDisplay.LoadDataRow(new object[] {newName}, true);
}
TheGrid.DataSource = filesToDisplay;
TheGrid.DataBind();
</string></string>