开发者

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(".开发者_StackOverflow/file.file");

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜