简体   繁体   中英

WP8 save isolated storage file to physical file

I was created a recorder to save sound, I store the sound to Isolated Storage and used the following code to get the path:

using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
{
   if (isoFile.DirectoryExists("/Sound/"))
   {
      var element = (FrameworkElement)sender;
      SoundData data = (SoundData)element.DataContext;

      string name = data.FilePath;
   }
}

I get the path is "/Sound/130215507805691237.wav" in Isolated Storage. But how to I save the sound to my phone as physical file? Thanks

Use MediaLibraryExtensions SaveSong method like this

MediaLibrary library=new MediaLibrary();
SongMetadata smd=new SongMetadata()
{
    AlbumName = "AlbumName",
    Duration = TimeSpan.FromMinutes(2.50),
    Name = "SongName" 
};
MediaLibraryExtensions.SaveSong(library, new Uri(filePath, UriKind.RelativeOrAbsolute), smd, SaveSongOperation.CopyToLibrary);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM