Microsoft KB Archive/183344

{|
 * width="100%"|

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

 * }

Q183344

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * Microsoft Windows 95

-

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.

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", ... ) Additional query words:

Keywords : kbAPI kbKernBase kbGrpDSKernBase

Issue type : kbbug

Technology : kbAudDeveloper kbWin32sSearch kbWin32API