Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MediaLibraryExtensions.SaveSong Method

Adds the specified song to the specified MediaLibrary.

public static Song SaveSong (
         MediaLibrary library,
         Uri filename,
         SongMetadata songMetadata,
         SaveSongOperation operation


Type: MediaLibrary
The media library to which the song is to be added.
Type: Uri
The path to an MP3 or WMA song file in the local file system.
Type: SongMetadata
Metadata about the song. If this argument is null, then the metadata contained in the song file is used.
Type: SaveSongOperation
An enumeration value that specifies whether to copy or move the song file.

Return Value

Type: Song
The added Song.

You cannot use the isostore Uri scheme to provide a value for the filename argument.

If the provided filename is not valid, the following exceptions can occur:

  • If the value is null, an ArgumentNullException occurs.
  • If the value contains an empty string, an InvalidOperationException occurs.
  • If the value points to a file that does not exist, an InvalidOperationException occurs.

If you do not provide a value for the songMetadata parameter, then the metadata contained in the song file is used.

When the expected metadata values are not provided or found in the song file, the following values are used:

  • The filename is used as the value of the Name property.
  • The value of properties of type String are set to Unknown.
  • The value of properties of type Uri remain null.

Capabilities for Windows Phone

If you use this API in your Windows Phone app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.

ID_CAP_MEDIALIB_AUDIOWindows Phone 8, Windows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone.

Namespace: Microsoft.Xna.Framework.Media.PhoneExtensions
Assembly: Microsoft.Xna.Framework.Media.PhoneExtensions (in

Windows Phone

Community Additions

© 2016 Microsoft