Orm
Orm

Reputation: 507

Question about file handling

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.

Upvotes: 0

Views: 128

Answers (2)

Amber
Amber

Reputation: 527378

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.

Upvotes: 2

womp
womp

Reputation: 116987

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.

Upvotes: 2

Related Questions