Loading Album art with TagLib sharp and then saving it to same/different file in C# causes memory error

后端 未结 3 654
余生分开走
余生分开走 2021-02-10 13:19

My application lists all MP3\'s in a directory and when the user selects a file it loads the tag info, including album art. The art is loaded into a variable to be used when the

3条回答
  •  抹茶落季
    2021-02-10 14:00

    Thanks for the help Jim but I couldn't really get it working using the 'using' blocks so I'm guessing the stream was still closing somewhere. I found another way to do what I was looking for by storing/saving a byte[] instead of an Image. And then just saving it using:

    using (MemoryStream ms = new MemoryStream(currentImageBytes))
    {
        pic.Data = TagLib.ByteVector.FromStream(ms);
        f.Tag.Pictures = new TagLib.IPicture[1] { pic };
        if (save)
            f.Save();
    }
    

提交回复
热议问题