是否可以编辑ByteArray的标签,该标签表示具有TagLib#的Mp3文件?
目前我需要这样做:
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; }
}