Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

List management, how to do it correctly?

$
0
0
Backstory: I saw that I had many projects in my Visual Studio 2010/2012 folders and decided to make a project "manager" for them. So far, I came to the conclusion that managing the paths to the files in a List was cleverer than using a String array, because I could actually manage the List better.

Here's the twist: I don't know how!

Problem: I have a foreach loop that goes through the whole list, and when there's an occurrence in the string (say I wanna delete every entry from the list that goes to the "/obj" directory and keep all the other ones), I would just say list.Remove(item)... But then the foreach loop cries; the List has changed during the process and calls an error.

Question: How do you mass-manage the list so that you can get rid of the unneeded ones faster?

Additional question: What would be an efficient way to find or to get the code to "understand" the path, so I can manage it better? I mean, if I want to know what directory I'm in without substringing and mathing the hell out of the strings to get the 3rd parent directory, is there a Lib or some sort of magical path-understanding method? One way I found would be to separate each string at the "\" and storing each "layer" of directory in an array to then be able to virtually go through them... But that seems inefficient...

Thanks in advance!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>