Thanks for taking the time to read this.
My problem is below.
I have two directories with music in them. one on my C: the other on a removable drive. I use dir > list.txt to output a list of the contents of both folders. I want to build a program that will compare the two text files and show me what is in the C: and not in the H:
i have the GUI developed and some basic code, however, i am undersure how to do the actual comparision. Any help would be appreciated.
Many thanks

Compare two text files
AustTech
just had a little attempt to build it there.
one question - the sample code you provided, would i attach that to a tree directory control
Also, i plan to use an input dialog to acquire the directory names from the user, and store this in a variable, and pass it to the GetDirectoryInfo method - should about right
Cheers again for your help!
jlavallet
What I’d probably do is at least display the files in a listview control (or some other UI), and set it for multi-selection – then I’d add a button that, when clicked, would copy the selected files in the listview to H:. Extra credit points for displaying both directories (the C:\ one and the H:\ one) in two listview (or whatever) controls, highlighting the differences between the two (say, red for files in C: and not H:, and blue for vice-versa), and having appropriate buttons to transfer them in either direction – that would be kind of cool, and would support the case where you’re actually moving music from one machine to the next via (for example) a flash card.
Regarding the input directory names: what I’d do is create an edit box for each, and put a button beside each that, when pressed, would bring up the file directory dialog (and populate the edit box with the result) so that the user could either type in the path or select it from a dialog.
--Matt--*
miteshpNOSPAM
So, assuming that the set of songs on H: are larger than the set of songs in C:, probably what I’d do (using VS2005) is read in the data from H into a list of strings (“Dim HList As List(Of String)” and “HList.Add(SomeHFilename)”), and then read in the data from C: -- I’d check to see if the item was already in the list (“if HList.BinarySearch(SomeCFilename) >= 0 Then…”), and if it wasn’t, then I’d add it to a second list which would end up containing everything on C: that wasn’t on H. There are other ways to do this, but basically you’ll have to create some sort of array to compare against.
However, I’d probably ditch the idea of doing dir > list.txt altogether and just read in the filelists directly from the operating system, to make this a one-step process. Something like
Dim CDirInfo As System.IO.DirectoryInfo
CDirInfo = My.Computer.FileSystem.GetDirectoryInfo("C:\somedirectory")
Dim CFiles() As System.IO.FileInfo = CDirInfo.GetFiles()
Dim MissingFiles As New List(Of String) ' or your favorites collection type, if not using VS2005
For Each CFile As System.IO.FileInfo In CFiles
If Not My.Computer.FileSystem.FileExists("H:\someother directory\" & CFile.Name) Then
MissingFiles.Add(CFile.Name) ' Or just Console.WriteLine(CFile.Name), or whatever
End If
' (…display MissingFiles to the user, etc…)
Next
(You’d have to worry about duplicate names if subdirectories are involved, so you might want to check against partial paths rather than filenames, to distinguish between all of the covers of “Blue Suede Shoes” or whatever. To do this, simply use other members of the FileInfo class to get path information. You can also get other file information from FileInfo, to check sizes or whatnot. The directory names on C: and H: should also probably be passed in via arguments or from the GUI rather then hard-coded, but you get the idea.)
Hope this helps!
--Matt Gertz--*
VB Compiler Dev Lead
luscher
monkzen
wow, thanks for that!
it certainly give me a good insight into the scope with which i have to work.
i'll do some more reading into it, cheers again!