Results 1 to 4 of 4

Thread: [RESOLVED] Icon -> Base64 encoding.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Resolved [RESOLVED] Icon -> Base64 encoding.

    I want to encode an icon in order to store it in a XML file , I have many Base64 encoder but the problem is that I want to know how to encode an icon.

    I thought that I should open it for binary & send the retrieved string to my encoders but opening icons for binary always give me error 62 past end of file , I made a search here & I found topics marked as resolved about this but all methods in it either fail or give my the same error , so any ideas about how to do this , thanks.
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Icon -> Base64 encoding.

    This one
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Icon -> Base64 encoding.

    VB Code:
    1. Private Sub LoadIcon(f As String)
    2. Dim b() As Byte
    3.  
    4.   Open f For Binary As #1
    5.   ReDim b(LOF(1))
    6.   Get #1, 1, b
    7.   Close #1
    8.  
    9.   'b is an array of byte that holds the entire .ico file contents.
    10.   'if you need it as a string ...
    11.  
    12. Dim s As String, i As Integer
    13.   For i = 0 To UBound(b) - 1
    14.     s = s & Chr$(b(i))
    15.   Next i
    16.  
    17. End Sub
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: Icon -> Base64 encoding.

    Both work (but with "i As Long" in the second).

    Thanks
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

Posting Permissions

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



Click Here to Expand Forum to Full Width