BUG: OpenFile Fails in Windows 95 When Using a Relative Path

ID: Q183344

The information in this article applies to:

SYMPTOMS

In Windows 95, if you run a Win32 program, change the process directory to the parent or some other ancestor directory, and then use OpenFile() to open a file in the original process directory using a minimum relative path, it will always fail with ERROR_FILE_NOT_FOUND.

RESOLUTION

On Win32 platforms, you need to use CreateFile() to open a file. If you are using OpenFile() for cross-platform compatibility, the function should be supplied with a full path or a better qualified path (that is, one that begins with a period).

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

Write a Win32 program that will run from C:\Temp\Debug. The program should call SetCurrentDirectory("C:\\Temp"). Then, the program should try to open a file in the original process directory using a minimum relative path as follows:

   OpenFile( "DEBUG\\TEST.TXT", ... )

This call fails with ERROR_FILE_NOT_FOUND. A call to GetCurrentDirectory() correctly returns C:\Temp.

The error only occurs with the minimum relative path shown above. The error does not occur if you use a full path in the OpenFile() call or if you use a better qualified path:

   OpenFile( ".\\DEBUG\\TEST.TXT", ... )
Keywords          : kbAPI kbKernBase kbGrpKernBase 
Version           : Win95
Platform          : Win95
Issue type        : kbbug
Solution Type     : kbnofix

Last Reviewed: April 3, 1998