CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Location
    Texas
    Posts
    4

    opening binary file

    I need to open a binary file and save it to an access 4.0, but I can't figure out how to open it in a way that I can then move it into an ado recordset.


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: opening binary file

    Function FileText(ByVal filename As String) As String
    Dim handle As Integer

    ' ensure that the file exists
    If Len(Dir$(filename)) = 0 Then
    Err.Raise 53 ' File not found
    End If

    ' open in binary mode
    handle = FreeFile
    Open filename$ For Binary As #handle
    ' read the string and close the file
    FileText = Space$(LOF(handle))
    Get #handle, , FileText
    Close #handle
    End Function


    now add this to your recordset

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Location
    Texas
    Posts
    4

    Re: opening binary file

    Thanks, that worked and showed me that I didn't know how to save a binary file to an OLE field. I tried to do the way I save and transfer other fields: adorec!Picture = bFile I called your function like this: Call FileText(bFile) It might be because I need to dim bFile as a Variant, I'll try it tonight.


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: opening binary file

    Rate it if it helped you

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured