Results 1 to 7 of 7

Thread: [RESOLVED] String Issues with FileGet

  1. #1
    nevafuse is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Nov 2008
    Posts
    4
    Reputation
    0

    Exclamation [RESOLVED] String Issues with FileGet

    I have a class that pulls the ID3 information from an MP3 file. This information is at the very end of the file in plain ASCII. The original author is using FileGet to retrieve just the last 127 characters of each mp3 file. The issue is that this information is put into strings declared like this...

    Code:
    Public strTag As New String(" ", 3)
    Public strTitle As New String(" ", 30)
    Public strArtist As New String(" ", 30)
    
    FilePut(intFile, strTitle)
    FilePut(intFile, strArtist)
    FilePut(intFile, strAlbum)
    This part all works fine. But I'm trying to code a property that returns a string like this...

    Code:
    return strTitle & " - " & strArtist
    But for some odd reason it is being very strict about the length of the returned string. It usually just returns the strTitle, and not the " - " or strArtist, and if I switch the positions, it will just return strArtist. So obviously both Strings have information in them.

    I'm an intermediate programmer, but just breaking into VB.NET. I'm not sure what the New String(" ",30) part does, but it is definitely interfering with the string concatenation that I'm trying to return. Anyone ever had a similar issue?

    I've tried String.Copy, String.Concat, etc. I've also tried doing ReadtoEnd(), but it takes forever for just 10 mp3 files, so I can't imagine how long it would take with a whole library. The only thing that slightly works is if I do...

    Code:
    return strTitle.SubString(0,5) & " - " & strArtist.SubString(0,5)
    But like I said, coincidentally it will only return around 30 characters.
    Last edited by nevafuse; 11-17-2008 at 2:04 PM. Reason: Problem solved.

  2. #2
    nevafuse is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Nov 2008
    Posts
    4
    Reputation
    0

    Testing Sample

    Here is a quick excerpt if you'd like to play around with it...

    Code:
    Imports System
    Imports System.IO
    
    Dim strTag As New String(" ", 3)
    Dim strTitle As New String(" ", 30)
    Dim strArtist As New String(" ", 30)
    'change this to the path for your mp3 file
    Dim strFilename As String = "C:\song.mp3"
    Dim intFile As Integer = FreeFile()
    FileOpen(intFile, strFilename, OpenMode.Binary, _
               OpenAccess.ReadWrite, OpenShare.LockWrite)
    Dim lngLOF As Long = LOF(intFile)
    If (lngLOF > 128) Then
                ' Check for the ID3v1 tag
                FileGet(intFile, strTag, lngLOF - 127, True)
                If (strTag.ToUpper = "TAG") Then
                    FileGet(intFile, strTitle)
                    FileGet(intFile, strArtist)
                    MsgBox(strTitle & " - " & strArtist)
                Else
                    MsgBox("No ID3 Info")
                End If
    End If

  3. #3
    nevafuse is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Nov 2008
    Posts
    4
    Reputation
    0
    Nevermind. Problem solved.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,188
    Reputation
    2368
    The Id3 tag version you're using is 1.0/1.1, which had 30 chars limit for those fields.

  5. #5
    Relentless is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2011
    Posts
    1
    Reputation
    0

    How?

    Ok, so how was this resolved cause I am having the same problem?

  6. #6
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,188
    Reputation
    2368
    I recommend using one of ID3 libraries out there, and to use v2 rather than the old v1. Here's one library: UltraID3Lib (it also supports v1 if you need to read those)

  7. #7
    nevafuse is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Nov 2008
    Posts
    4
    Reputation
    0

    Terminating character

    Although this issue was forever ago...

    I think the issue was that I was getting a terminating character in my string. This caused output not to returning anything past the terminating character.

    I wish I could give you the ascii number or hex string, but I don't remember. Good luck.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking