Hi Dseligo
I've spent the last couple of evening having a go with this, and perhaps given your appetite to help you'll allow me to add some flesh to the bones.
1) The reason I use stringlists is two fold. a) It allows me, if I use FindAllFiles first, to generate a figure of how many files are in FolderA and FolderB, and b) it provides me the filename and path all on one string, which my hash function needs as it expects the path to a file, and the filename. So for that reason, FindFirst and FindNext I don't think are quite the ticket (I did start to try but quickly realised that although Filename is easily accessible, file path, especially once you dig into sub-folders of the selected top level folder, becomes tricky\messy.
2) What I am trying to achieve is based not so much on filename, but file hash,, and allowing the user to know that the file CONTENT of two folder are the same, or not. So FolderA could have 3 files in it called A.txt, B.txt and C.txt. FolderB could have copies of the exact same three files, but be called D.txt, E.txt and F.txt. In that case, I need it to report a match based on hash and filecount even if the filenames differ.
3) And so herein is the problem. As you saw from post 1, it works fine using sorted stringlists when the filecount is the same. Everything is kept in line. But if one folder contains less than the other, and because I need to have one DBGrid with the content of FOlderA on one side and the content of FolderB on the other, I am having to use UPDATE in SQL, instead of INSERT. INSERT of course adds rows. UPDATE updates existing rows. But if a file is missing, and the cells are empty, then UPDATE places the next entry in that. What I need to do is somehow mark it as blank. That is what I was hoping to do because aside from this one issue, the rest of it works perfectly.
I have attempted to implement some of your suggestions but, as you have just illustrated, if I stick with stringlists, and I stick with two InsertHash routines, it's not a million miles away from what I have now I think, so I'm not quite sure whether to try again or keep pursuing. Your implementation is better of course, but I don't understand all of it and so far I have only got as far as showing the results of of all the files from both FolderA and FolderB all in one column, with hashes for FolderA in Column2, and then hashes for FolderB in Column 3.
It's all making my head hurt to be honest. So much so I am thinking of just discarding the functionality. The only probelm is a lot of people use it and like it (at least for instances where the filecounts are the same). I need to think outside the box somehow. You have two folders. One has less files than the other, but you don't know which file(s) are missing until you have itterated both folders and hashed all the files. How to I display that, in a DBGrid? That is my challenge.
By the way, if you want to see this issue for yourself, go to
www.quickhash-gui.org and run the program (full code of latest branch not including your suggestion yet is
https://github.com/tedsmith/quickhash/tree/v3.3.0). Create two folders, with matching files first, and then remove one from FolderB. Use the 'Compare Two Folders' tab and it might make more sense to you.