CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: binary file i/o

  1. #1
    Join Date
    Sep 2000
    Location
    Ottawa, Ontario
    Posts
    356

    binary file i/o

    How do I read/write a file 1 byte at a time? I tried using OPEN "file.bin" for binary read. This works but is very slow. I looked at the FileSystemObject but only seem to find Textfileopen and write. Can the FSO do binary? is there a better way then the old OPEN command?

    Jean-Guy


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

    Re: binary file i/o

    'to write
    Open App.Path & "\temp.enc" For Binary As #1
    Put #1, 1, 0 '#file,position,char
    Put #1, 2, 128
    Put #1, 3, 0
    Put #1, 4, 128

    'to read
    Open InFile For Binary As #2
    Do While Not EOF(2)
    'Add one to the record number to obtain
    pos = pos + 1
    'Obtain the next character in the infile
    Get #2, pos, char '#file, pos,char
    'Write the next character in the infile
    Put #1, pos + 4, char + 128
    Loop
    Close #2
    Close #1


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

  3. #3
    Join Date
    Sep 2000
    Location
    Ottawa, Ontario
    Posts
    356

    Re: binary file i/o

    I wanted to do it without using open binary. I was wondering if it can be done with the FSO.

    Jean-Guy


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