Using the Windows API, what is the longest directory path (excluding filename) that Windows Explorer can handle?
- 260
- 248
- 192
- 512
EXPLANATION
In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string<NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)
Note
File I/O functions in the Windows API convert "/" to "\" as part of
converting the name to an NT-style name, except when using the "\\?\"
prefix as detailed in the following sections.
Note
The maximum path of 32,767 characters is approximate, because the
"\\?\" prefix may be expanded to a longer string by the system at run
time, and this expansion applies to the total length.There is no need to perform any Unicode normalization on path and file name strings for use by the Windows file I/O API functions because the file system treats path and file names as an opaque sequence of WCHARs. Any normalization that your application requires should be performed with this in mind, external of any calls to related Windows file I/O API functions.
When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name (that is, the directory name cannot exceed MAX_PATH minus 12).
The shell and the file system have different requirements. It is possible to create a path with the Windows API that the shell user interface is not able to interpret properly.
0 comments:
Post a Comment