?
Solved

Compare the folder

Posted on 1999-12-30
10
Medium Priority
?
125 Views
Last Modified: 2010-05-18
What's the best method to find the different files from  A folder and B folder ?
0
Comment
Question by:ginlu
  • 6
  • 3
10 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2314429
Here's the easy way:

* Create a list of files in folder A -> save in Array1
* Create a list of files in folder B -> save in Array2
* Add the characters ",1" to every item in Array1
* Add Array2 to Array1, be sure to add ",2" to every item
* Sort Array1
* Iterate thru all items in Array1, and see what non-duplicates exist (duplicates here means where everything but the two characters are the same)
0
 

Accepted Solution

by:
jimkan earned 40 total points
ID: 2314590

Use a reference to Microsoft Scripting Runtime. It always exists among your references.

Dim oObject As New FileSystemObject
Dim oFolder As Folder
Dim oFile   As File
Dim oArray As New Scripting.Dictionary

Set oFolder = oObject.GetFolder(App.Path & "\Ko")
For Each oFile In oFolder.Files
    oArray.Add oFile.Name, 1
Next oFile

Set oFolder = oObject.GetFolder(App.Path & "\Ka")
For Each oFile In oFolder.Files
    If not oArray.Exists(oFile.Name) Then txtFiles.SelText = oFile.Name & " does not exist in " & oFolder.ShortPath & vbNewLine
Next oFile
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2314722
jimkan: it does NOT always exist there!! <g>

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Expert Comment

by:jimkan
ID: 2314846
I have so far never seen a machine that got VB installed that do not have Microsoft Scripting RunTime among his/her references.
Microsoft Scripting Runtime is included in the Internet Explorer Package.
If you are a VB coder that do not use Internet Explorer, then it may be missing, but then those coders aint many =).
0
 

Expert Comment

by:jimkan
ID: 2314854
Just forgot:

Let ginlu check if he got Microsoft Scripting Runtime in
"Projects => References"

Sincererly Jim
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2314906
Well, I don't think you've seen that many machines then. I am proud of belonging to 'the few people' according to you that do NOT have it installed. ;)
0
 

Author Comment

by:ginlu
ID: 2316011
Thanks for your answer!
But this kind of compare is just find different filename ,how can i find out the change files....
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2316397
If you use the 'system' I mentioned you can store date too i.e. you get

\Directory\Filename.Ext,1999-10-12 01:01:01,1

This will make the two

\Directory\Filename.Ext,1999-10-12 01:01:01,1
\Directory\Filename.Ext,1999-10-12 01:01:02,2  <- one sec newer

different and it will still be left when you have iterated thru the array. You will have to ignore everything you get on the last step that has a ",1" as 2 last characters.

I think I can fix you up with some code if you get stuck, but I let you try this first ;)


0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2316398
If you use the 'system' I mentioned you can store date too i.e. you get

\Directory\Filename.Ext,1999-10-12 01:01:01,1

This will make the two

\Directory\Filename.Ext,1999-10-12 01:01:01,1
\Directory\Filename.Ext,1999-10-12 01:01:02,2  <- one sec newer

different and it will still be left when you have iterated thru the array. You will have to ignore everything you get on the last step that has a ",1" as 2 last characters.

I think I can fix you up with some code if you get stuck, but I let you try this first ;)


0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2316399
Sorry for the duple-post, I really like double-clicking on things I guess.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question