是否可以使用 TagLib# 编辑代表 Mp3 文件的 ByteArray 的标签?
目前我需要这样做:
System.IO.File.WriteAllBytes(path + file + ".mp3", byt);
TagLib.File f = TagLib.File.Create(path + song + ".mp3");
是否可以避免这种情况并直接从 ByteArray 创建 TagLib.File?
尝试这个:
var file = TagLib.File.Create(new FileBytesAbstraction(<file name>, <file bytes>));
FileBytesAbstraction 在哪里:
public class FileBytesAbstraction : TagLib.File.IFileAbstraction
{
public FileBytesAbstraction(string name, byte[] bytes)
{
Name = name;
var stream = new MemoryStream(bytes);
ReadStream = stream;
WriteStream = stream;
}
public void CloseStream(Stream stream)
{
stream.Dispose();
}
public string Name { get; private set; }
public Stream ReadStream { get; private set; }
public Stream WriteStream { get; private set; }
}