I am converting a VB6 project to C#. I have come across some VB6 that I don't totally understand (and I don't have the ability to debug at all). It is a loop which exits immediately, before doing anything:
For Each objSubFolder In objFolder.SubFolders
Exit For
Next
Can anyone explain that? I'm sure it does something. I'm guessing it is assigning a variable, or something. If so, does it do it only once?
If objSubFolder exists outside the scope of the For Each (as per you comment), the code would be roughly the equivalent of this c#
var folders = Directory.GetDirectories(@"c:\someFolder");
var firstFolder=folders.FirstOrDefault();
i.e. find the first subfolder of a given folder (if it exists).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With