Is there an easier way to reconcile a list of files and a directory with subfolders/files to find ch

Posted by rwmnau on Stack Overflow See other posts from Stack Overflow or by rwmnau
Published on 2010-06-03T06:17:14Z Indexed on 2010/06/03 10:24 UTC
Read the original article Hit count: 152

Filed under:
|
|

I have a SQL Server table with a list of files (path + filename), and a folder with multiple layers and files in each layer. I'm looking for a way to reconcile the two without having to process the list twice. Currently, I'm doing this:

For Each f as FileInfo In FileListFromDatabase
   If f.Exists is False, mark it as deleted in the database
Next

For Each f as FileInfo In RecursiveListOFFilesOnDisk
   If Not FileExistsInDatabase, then add it
Next

Is there a better way to do this? I'd like to avoid converting all the matching files (of which most will be) to FileInfo objects twice. Since I'm a T-SQL developer first, I'm picturing something like an OUTER JOIN of the two lists where they don't match. Something LINQ-ish?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about system.io