We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 133,040 times

Contents

Related Categories

Binary Files - File Access

File Access

First, lets remind ourselves of how we access files in VB. The first step is to get a free file number using the FreeFile method. We then use the Open statement to open the file, specifying any options we want:

nFileNum = FreeFile
Open sFile For Binary Access Write Lock Read Write As #nFileNum

In this case, we open the file specified in sFile for binary write access (Binary Access Write), and prevent the file from being read and modified by other programs (Lock Read Write).

We would then read or write to the file as necessary, and when finished call the Close method:

Close #nFileNum

Now that we've quickly reminded ourselves of how file access works, we can get on to outputting a binary file.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments