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:
- The directory where an application is loaded.
- The current directory.
- The Windows system directory.
- The 16-bit Windows system directory.
- The Windows directory.
- 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.
精彩评论