PRB: Permission Denied When Using BLOAD to Load Open File (112045)



The information in this article applies to:

  • Microsoft Visual Basic for MS-DOS
  • Microsoft QuickBASIC 4.5
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q112045

SYMPTOMS

Using BLOAD to load a file into memory when that file is already open with write access results in error 5, "Permission Denied."

CAUSE

When you try to use BLOAD to load an open file that was opened for SHARED or ACCESS READ WRITE, you are denied permission. This is by design.

RESOLUTION

If you need to use BLOAD to load a file that is already open, either close the file or make sure the file was opened for ACCESS READ.

STATUS

This behavior is by design.

MORE INFORMATION

How to Reproduce the Behavior

The following code segment results in the "Permission Denied" error:
OPEN "C:\TEST.SAV" FOR RANDOM SHARED AS #1
BLOAD "C:\TEST.SAV"                         'Error 5 occurs here

NOTE: C:\TEST.SAV must be a valid BSAVE file.
				

WORKAROUND

The following code segment shows how to open the data file for readonly access so that the BLOAD statement does not generate an error:
OPEN "C:\TEST.SAV" FOR RANDOM ACCESS READ AS #1
BLOAD "C:\TEST.SAV"                          'No error
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:kbprb KB112045