none
List files in directory in VB (VBListFilesInDirectory) RRS feed

  • Question

  • I wish to get also the metada for audio files such as Author, Title, SUbject, Year...
    Monday, November 5, 2018 1:04 AM

All replies

  • Hi,

    try the code:

    Imports System.IO
    
    Module Module1
    
        Sub Main()
            Dim b As Byte() = New Byte(127) {}
            Dim sTitle As String
            Dim sSinger As String
            Dim sAlbum As String
            Dim sYear As String
            Dim fs As FileStream = New FileStream("D:\test.mp3", FileMode.Open)
            fs.Seek(-128, SeekOrigin.[End])
            fs.Read(b, 0, 128)
            Dim isSet As Boolean = False
            Dim sFlag As String = System.Text.Encoding.[Default].GetString(b, 0, 3)
    
            If sFlag.CompareTo("TAG") = 0 Then
                System.Console.WriteLine("Tag is setted!")
                isSet = True
            End If
    
            If isSet Then
                sTitle = System.Text.Encoding.[Default].GetString(b, 3, 30)
                System.Console.WriteLine("Title:" & sTitle)
                sSinger = System.Text.Encoding.[Default].GetString(b, 33, 30)
                System.Console.WriteLine("Author:" & sSinger)
                sAlbum = System.Text.Encoding.[Default].GetString(b, 63, 30)
                System.Console.WriteLine("SUbject:" & sAlbum)
                sYear = System.Text.Encoding.[Default].GetString(b, 93, 4)
                System.Console.WriteLine("Year:" & sYear)
    
            End If
    
            System.Console.WriteLine("Any key to exit!")
            System.Console.Read()
        End Sub
    
    End Module
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 5, 2018 3:24 AM