Open korimato opened 7 years ago
Solved!
I change the part where we get the streams for this:
StorageFolder musicLibrary = KnownFolders.MusicLibrary;
StorageFile songTest = await musicLibrary.GetFileAsync("3160142.mp3");
var stream = await songTest.OpenAsync(FileAccessMode.ReadWrite);
var readStream = stream.AsStreamForRead();
var writeStream = stream.AsStreamForWrite();
var tagFile = TagLib.File.Create(new StreamFileAbstraction(songTest.Name, readStream, writeStream));
And in the end, after to save()
readStream.Dispose();
writeStream.Dispose();
I'm working on an UWP (Visual Studio Tools For UWP 14.0.25527.01. TagLib.Portable 1.0.3. from NuGet). My app get songs stored in Music Library and adds tags to them. The problem is each time I call to
tagLibFile.save()
it throws an exception:"The system cannot find the file specified. (Exception from HRESULT: 0x80070002)":null}"
This is the code I actually use:
`StorageFolder musicFolder = KnownFolders.MusicLibrary; songStorageFile = await musicFolder.GetFileAsync("songTest.mp3"); var stream = await songStorageFile.OpenStreamForWriteAsync();
TagLib.Id3v2.Tag.DefaultVersion = 3; TagLib.Id3v2.Tag.ForceDefaultVersion = true;
var tagFile = TagLib.File.Create(new StreamFileAbstraction(songStorageFile.Name, stream, stream)); var tags = tagFile.GetTag(TagTypes.Id3v2); tags.Title = "my custom title";
tagFile.Save();`
The craziest thing is despite of the exception, once I close the app debug the original file is updated with all changes.
Also, with a breakpoint, I have checked
songStorageFile
,stream
andtagFile
vars and they're correctly loaded (they points ok to the file).This errors occurs me in Windows 10 and Windows 10 Mobile (Lumia 640).