Retrieves the full path and file name of the specified file.
To perform this operation as a transacted operation, use the GetFullPathNameTransacted function.
For more information about file and path names, see File Names, Paths, and Namespaces.
DWORD GetFullPathNameA( LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR *lpFilePart );
The name of the file.
This parameter can be a short (the 8.3 form) or long file name. This string can also be a share or volume name.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function (GetFullPathNameW), and prepend "\?" to the path. For more information, see Naming a File.
The size of the buffer to receive the null-terminated string for the drive and path, in TCHARs.
A pointer to a buffer that receives the null-terminated string for the drive and path.
A pointer to a buffer that receives the address (within lpBuffer) of the final file name component in the path.
This parameter can be NULL.
If lpBuffer refers to a directory and not a file, lpFilePart receives zero.
If the function succeeds, the return value is the length, in TCHARs, of the string copied to lpBuffer, not including the terminating null character.
If the lpBuffer buffer is too small to contain the path, the return value is the size, in TCHARs, of the buffer that is required to hold the path and the terminating null character.
If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError.
GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file. It also calculates the address of the file name portion of the full path and file name.
This function does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.
Note that the lpFilePart parameter does not require string buffer space, but only enough for a single address. This is because it simply returns an address within the buffer that already exists for lpBuffer.
Share and volume names are valid input for lpFileName. For example, the following list identities the returned path and file names if test-2 is a remote computer and U: is a network mapped drive whose current directory is the root of the volume:
- If you specify "\\test-2\q$\lh" the path returned is "\\test-2\q$\lh"
- If you specify "\\?\UNC\test-2\q$\lh" the path returned is "\\?\UNC\test-2\q$\lh"
- If you specify "U:" the path returned is the current directory on the "U:\" drive
If the return value is greater than or equal to the value specified in nBufferLength, you can call the function again with a buffer that is large enough to hold the path. For an example of this case in addition to using zero-length buffer for dynamic allocation, see the Example Code section.
In Windows 8 and Windows Server 2012, this function is supported by the following technologies.
|Server Message Block (SMB) 3.0 protocol||Yes|
|SMB 3.0 Transparent Failover (TFO)||Yes|
|SMB 3.0 with Scale-out File Shares (SO)||Yes|
|Cluster Shared Volume File System (CsvFS)||Yes|
|Resilient File System (ReFS)||Yes|
#include <windows.h> #include <tchar.h> #include <stdio.h>
|Windows version||Windows XP [desktop apps||UWP apps] Windows Server 2003 [desktop apps||UWP apps]|
|Header||fileapi.h (include Windows.h)|