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", true, null)) { iMP3Count += 1; } } return iMP3Count; } |
+
bei dem dick geschriebenen setzt sich mein Wert immer wieder zurück. Was muss ich ändern?
Moderiert von
Christian S.: C#-Tags hinzugefügt