private void saveSongs() { try { using (FileStream stream = new FileStream(@"../../library/songs.xml", FileMode.Truncate)) { XmlSerializer serializer = new XmlSerializer(typeof(List <AudioMedia>)); serializer.Serialize(stream, ListSongs.ToList()); }; } catch (Exception) { MessageBox.Show("Error occured when saving songs library" + Environment.NewLine + "Be sure you've correct permissions", "Library Error", MessageBoxButton.OK, MessageBoxImage.Error); } }