private void OnExportPlaylist(object o, EventArgs args) { AbstractPlaylistSource source = ActionSource as AbstractPlaylistSource; if (source == null) { return; } source.Activate(); PlaylistExportDialog chooser = new PlaylistExportDialog(source.Name, PrimaryWindow); string uri = null; PlaylistFormatDescription format = null; int response = chooser.Run(); if (response == (int)ResponseType.Ok) { uri = chooser.Uri; // Get the format that the user selected. format = chooser.GetExportFormat(); } chooser.Destroy(); if (uri == null) { // User cancelled export. return; } try { IPlaylistFormat playlist = (IPlaylistFormat)Activator.CreateInstance(format.Type); SafeUri suri = new SafeUri(uri); if (suri.IsLocalPath) { playlist.BaseUri = new Uri(System.IO.Path.GetDirectoryName(suri.LocalPath)); } playlist.Save(Banshee.IO.File.OpenWrite(new SafeUri(uri), true), source); } catch (Exception e) { Console.WriteLine(e); Log.Error(Catalog.GetString("Could not export playlist"), e.Message, true); } }