comparing 2 arrays

D

David

Hi all,

How would I go about this?

I am doing a document management system and I need to write a clean up
routine.

I will create two arrays. One of them will have a list of filenames I have
dragged from a database (I actually have to parse strings to get filenames,
but I can already do that). I will be inserting the file names into an
arraylist.

The second arraylist will be a result of reading the filesystem.

What I want to do is then cross compare. Basically, any surplus files from
the filesystem arraylist will be deleted, so I need to know if the file in
the filesystem is in the filelist from the database.

Any ideas on how I can do this would be appreciated.

Best regards,
Dave Colliver.
http://www.LeedsFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
K

Karl Seguin

The arraylist contains a useful member called Contains. I'd make use of it.

foreach (string file in fileSystemList)
{
if (!databaseList.Contains(file))
{
//file needs to be deleted
}
}

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

comparing two arrays, too slow 5
comparing lists 7
Tasks 1
Load Balancing 5
Transactional webservice 5
Comparing strings from the back? 91
AJAX send a JS Alert 1
Creating my own functions in global.asax.cs 3

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top