Dieses kleine Snippet erstellt M3U-Playlisten, die auch mit deutschen Umlauten zurechtkommt, was der DOS-dir-Befehl nicht so recht kann
using System;
using System.Text;
using System.IO;
namespace DoenaSoft.Playlist
{
//Warum nicht einfach "dir *.mp3 /b > !playlist.m3u"?
//Weil der nicht mit deutschen Umlauten umgehen kann.
public static class Playlist
{
public static void Main(String[] args)
{
DirectoryInfo di;
FileInfo[] fis;
StringBuilder output;
if ((args == null) || (args.Length != 1) || (Directory.Exists(args[0]) == false))
{
Console.WriteLine("No path provided. Using current directory.");
args = new String[] { "." };
}
di = new DirectoryInfo(args[0]);
Console.WriteLine("Processing \"" + di.FullName + "\"");
fis = di.GetFiles("*.mp3", SearchOption.TopDirectoryOnly);
output = new StringBuilder();
foreach (FileInfo fi in fis)
{
output.AppendLine(fi.Name);
}
using (StreamWriter sw = new StreamWriter(di.FullName + @"\!playlist.m3u", false, Encoding.GetEncoding("Windows-1252")))
{
sw.Write(output.ToString());
}
}
}
}
1 Kommentare zum Snippet