Microsoft KB Archive/93057

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 10:25, 21 July 2020 by X010 (talk | contribs) (Text replacement - ">" to ">")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Trying to Delete Current Directory Gives Path Not Found Error

Article ID: 93057

Article Last Modified on 11/21/2006

This article was previously published under Q93057

SYMPTOMS

If you attempt to delete the current directory using the Basic RMDIR command, the incorrect run-time error 76 "Path not found" is returned. This error is returned even if the entire absolute path is provided. The correct error to return under this condition is run-time error 75, or "Path/File access error".

STATUS

Microsoft has confirmed this to be a bug in Microsoft QuickBasic for MS- DOS, version 4.5; in Microsoft Basic Professional Development System (PDS) for MS-DOS, version 7.1; and in Microsoft Visual Basic programming system for Windows, version 1.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The Basic RMDIR command is used to delete an existing directory from disk. In order for this command to function properly, the following requirements must be met:

  1. The directory must be empty of other directories and/or files.
  2. You cannot delete the current directory.

Attempting to delete the current directory (whether empty or not) will cause run-time error 76, or "Path not found" to be generated. Error 76 is not the correct error that should be reported, and is misleading. Instead the correct run-time error of 75, "Path/File access error" should be returned.

The following steps can be used to reproduce this problem:

  1. Start QB.EXE, QBX.EXE, or VB.EXE and enter the following code:

       MKDIR "C:\TEMPDIR"
       CHDIR "C:\TEMPDIR"
       RMDIR "C:\TEMPDIR"
       END
                            
  2. Run the program. A run-time error dialog box is displayed which contains a "Path not found" error.

To work around this problem, check the value of the CurDir$ function and compare it to the directory to be deleted. If the directories are different, it is safe to delete the directory. If the directories are the same, you must change to a different directory before executing the RMDIR command. The following code demonstrates this workaround:

  MKDIR "C:\TEMPDIR"
  CHDIR "C:\TEMPDIR"
  IF CURDIR$ <> "C:\TEMPDIR" THEN>
    RMDIR "C:\TEMPDIR"
  ELSE
    CHDIR ".."
    RMDIR "C:\TEMPDIR"
  END IF
  END
                


Additional query words: QuickBas BasicCom 4.50 1.00 7.10 buglist4.50 buglist1.00 buglist7.10

Keywords: KB93057