24. November 2008 03:20
So I recently bough the 120GB Zune and was a bit upset that the playlists I had created in Windows Media player did not work with the Zune. You would think Microsoft would let that happen since Windows Media Player can be used to organize media. Maybe I just haven't got used to the Zune software yet, but I think it's easier to organize it all in Windows Media Player than the Zune software. Anyway, so I wrote a very very simple C# program that will convert my windows media player playlists into a Zune playlists. So here is the code. It is littlerally a form with a Open File Dialog Box and a button.
private void btnBrowse_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.StreamReader sr = new
System.IO.StreamReader(openFileDialog1.FileName);
//MessageBox.Show(sr.ReadToEnd());
string playList = openFileDialog1.SafeFileName;
playList = playList.Remove(playList.LastIndexOf("."));
string wplDoc = sr.ReadToEnd();
wplDoc = wplDoc.Replace("wpl version=\"1.0\"", "zpl version=\"2.0\"");
wplDoc = wplDoc.Replace("src=\"..", "src=\"C:\\Users\\wtroom\\Music");
//MessageBox.Show(wplDoc);
System.IO.File.WriteAllText(string.Format("C:\\Users\\wtroom\\Music\\Zune\\Playlists\\{0}.zpl", playList), wplDoc);
MessageBox.Show("File Created Successfully");
sr.Close();
}
}
As you can see I am just changing the header to work with the Zune XML and changing the way the file is reference since in WMP it is with ..\.
Zune references it using the entire file path. Anyway this is a quick way to do it. I could definitely all the functionality of checking to see if the file exists if so give the user to overwrite it or not. Anyway, go ahead and build on from this. Just make sure to replace the file path with where you keep your Zune Playlists.
789618fd-3123-4dde-8a41-2f0f57b5faf1|1|3.0
Tags: zune, c#
C#