我创建了一个用于保存声音的录音机,我将声音存储到Isolated Storage并使用以下代码来获取路径:
using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isoFile.DirectoryExists("/Sound/"))
{
var element = (FrameworkElement)sender;
SoundData data = (SoundData)element.DataContext;
string name = data.FilePath;
}
}
我在隔离存储中得到的路径是“/Sound/130215507805691237.wav”。但是如何将声音保存到我的手机作为物理文件?谢谢
答案 0 :(得分:2)
像这样使用MediaLibraryExtensions
SaveSong方法
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);