tags:

views:

55

answers:

2

Hey, I wanted to know if anyone can tell me what the difference between "file.file" and "./file.file" is. It seems to make quite a significant difference in my programs to call OpenFile("./file.file");

EDIT: My mistake, I thought my question was a generic one. This is in C++ using standard library functions.

+2  A: 

In general, "./File" will be relative to the directory that your program's context is currently executing in.

Just "File" will be relative to the directory that the program executable resides in.

This is pretty dependent on what tool or language you're using, however.

womp
Thank you, that clears it up for me. Always good to know the reasons why something works than just roll with it.
Orm
+2  A: 

If you're referring to the WinAPI function, see the remarks section on this MSDN page:

Remarks

If the lpFileName parameter specifies a file name and extension only, this function searches for a matching file in the following directories and the order shown:

  1. The directory where an application is loaded.
  2. The current directory.
  3. The Windows system directory.
  4. The 16-bit Windows system directory.
  5. The Windows directory.
  6. The directories that are listed in the PATH environment variable.

The ./file.ext means that it must be in the current directory, whereas not specifying a directory means it can be in any of the places normally checked.

Amber