Mit dieser Sub kann man einen ID3v2-Tag von der source-MP3 in die dest-MP3 kopieren:
VB.NET-Quellcode
- Private Sub CopyID3Tag(ByVal source As String, ByVal dest As String)
- Dim bytes() As Byte, orgbytes() As Byte
- bytes = IO.File.ReadAllBytes(dest)
- orgbytes = IO.File.ReadAllBytes(source)
- Dim l As Long, orgl As Long
- l = Math.Pow(128, 3) * bytes(6) + Math.Pow(128, 2) * bytes(7) + 128 * bytes(8) + bytes(9)
- orgl = Math.Pow(128, 3) * orgbytes(6) + Math.Pow(128, 2) * orgbytes(7) + 128 * orgbytes(8) + orgbytes(9)
- Using bw As New IO.BinaryWriter(New IO.FileStream(dest, IO.FileMode.Open))
- Dim b(orgl + 10) As Byte
- Array.ConstrainedCopy(orgbytes, 0, b, 0, b.Length)
- bw.Write(b)
- Dim bb(bytes.Length - l - 11) As Byte
- Array.ConstrainedCopy(bytes, l + 10, bb, 0, bb.Length)
- bw.Write(bb)
- bw.Close()
- End Using
- End Sub