Entwickler-Ecke

C# - Die Sprache - Rekursive Counterschleife speichert Wert nicht


lodibach - Do 29.04.10 15:28
Titel: Rekursive Counterschleife speichert Wert nicht
Hallo,
ich habe ein Problem. Ich möchte eine rekursive Schleife programmieren, die alle .mp3 Dateien in einem Ordner (auch in dessen Unterordner) zählt. Meine Schleife steht auch schon & läuft soweit, doch ich weiß nicht wie ich den meine Variable speichern soll.

+

C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
FileInfo oFile = new FileInfo(sDateien[iFileindex]);
int iMP3Count = 0;
MigrateUtils.CUtils.GetMP3Count(new DirectoryInfo(sEingabeordner), iMP3Count);

        public static int GetMP3Count(FileSystemInfo oFileSystemInfo, int iMP3Count)
        {
            var oDirInfo = oFileSystemInfo as DirectoryInfo;
            
            if (oDirInfo != null)
            {
                foreach (var oDirEntry in oDirInfo.GetFileSystemInfos())
                {
                    GetMP3Count(oDirEntry, iMP3Count);
                }
            }
            else
            {
                if (oFileSystemInfo.Name.EndsWith(".MP3"truenull))
                {
                    iMP3Count += 1;
                }
            }
            
            return iMP3Count;
        } // GetMP3Count


+
bei dem dick geschriebenen setzt sich mein Wert immer wieder zurück. Was muss ich ändern?

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt


danielf - Do 29.04.10 15:32

Ist das ein Test?


Kha - Do 29.04.10 16:57

Kommt mir ein wenig bekannt vor :gruebel: ... hier [http://c-sharp-forum.de/viewtopic.php?t=99177] geht's weiter.