IHateMyselfx

ZeneClass1.cs

May 25th, 2023
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using NAudio.Wave;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6.  
  7. namespace MuiscPlayer
  8. {
  9.     public class ZeneClass1
  10.     {
  11.         public string FileName { get; set; }
  12.         public string FilePath { get; set; }
  13.  
  14.         public ZeneClass1(string fileName, string filePath)
  15.         {
  16.             FileName = fileName;
  17.             FilePath = filePath;
  18.         }
  19.         public override string ToString()
  20.         {
  21.             return FileName; // megjelenítse a zene címét
  22.         }
  23.  
  24.        
  25.         public static void LoadSongsFromFolder(string folderPath, List<ZeneClass1> songs)
  26.         {
  27.             try
  28.             {
  29.                 List<string> mp3Files = Directory.GetFiles(folderPath, "*.mp3", SearchOption.TopDirectoryOnly).ToList();
  30.  
  31.                 foreach (string file in mp3Files)
  32.                 {
  33.                     string fileName = Path.GetFileName(file);
  34.                     songs.Add(new ZeneClass1(fileName, file));
  35.                 }
  36.             }
  37.             catch (Exception)
  38.             {
  39.                 throw new Exception("Üres mappa!");
  40.             }
  41.         }
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment