I have a collection of zipfiles in a FileInfo object, and as I loop through them, I determine if I need it or not. When I run the code, I get following runtime error message...
Collection was modified; enumeration operation may not execute
Here is a sample pseudo, of what I have going on. Is there a simple way to work around this without making things too hairy? :-)
foreach (FileInfo zp in ZipFiles)
// Do some calculations. Determine if I don't need the zip file.
ZipFiles.Remove(zp);//remove zipfiles that I don't need
// Do some calculations. Determine if I do need the zip file.
ZipFiles.Add(fi);//add some new zipfiles that I do need.
}//end of foreach loop