Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello,
I have already setted up a button and everything, i just need to know how to setup a code for it to check between two folders..
that when i just click the button, it will access the folders without showing and compare them.
when its done, i need the files that werent found in Folder1 to be deleted in Folder2, but before deleting them I need it to save every files name before it deletes so it can be deleted from a ZIP two.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-12 17:49pm    
What have you done, except "a button and everything"? What's the problem? Why doing it, by the way? What do you use for ZIP?
--SA
NextGenDeveloper 26-Feb-12 7:32am    
Its for a game, install and uninstall mods, its alot of files. but i need it to detect the correct files, install is already done. uninstall isnt, i need it to fatch the zip files(mod) and compare it to a fresh install, if he wont find the right files, it will save in a String or List and wil delete from the modifeded zip, this means working with 3 zips.

1 solution

You can use System.IO.Directory.GetFiles, please see:
http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^].

For working with ZIP, you can use #ziplib:
http://www.icsharpcode.net/opensource/sharpziplib/[^].

Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:
http://en.wikipedia.org/wiki/7-Zip[^],
http://sevenzipsharp.codeplex.com/[^].

Both ZIP libraries are open-source.

—SA
 
Share this answer
 
v2
Comments
LanFanNinja 25-Feb-12 19:13pm    
+5
Sergey Alexandrovich Kryukov 25-Feb-12 19:49pm    
Thank you.
--SA
NextGenDeveloper 26-Feb-12 0:50am    
Thanks SA, but i have a problem. I cant find how to make it check bettwen 2 folders, and if it doesnt find files that are in Folder2 and not in Folder1, so i want them to get a name save(for the ZIP) and then deleted them in Folder2, not just 1 file but some files, without deleting the files that are found
Sergey Alexandrovich Kryukov 26-Feb-12 1:03am    
This is just a matter of your logic. One idea is this: create a Dictionary, System.Collections.Generic.Dictionary<string, Match>. For a key, use a string: file name (make it upper case or lower case) without the different (parent) part of directory name. In a dictionary value, use some "Match" structure: found in one location, in another, in both + any relevant information. Populate the dictionary from both directories to be compare. On second run, use only the dictionary: traverse all key-value pairs, and make the decision based on the value.
--SA
Monjurul Habib 26-Feb-12 6:11am    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900