Declare Function GetFullPathName Lib "kernel32.dll" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Platforms: Win 32s, Win 95/98, Win NT
GetFullPathName appends a specified filename to the name of the current directory. For example, if you specify the file "hello.txt" and the current directory is "C:\My Documents\Junk", the resulting filename would be "C:\My Documents\Junk\hello.txt". This string is put into the string passed as lpBuffer. The function returns 0 if an error occured, or the length of the final string if successful.
Example:
' Append the filename datafile.dat to C:\Programs\Test
Dim buffer As String ' receives path and filename string
Dim numchar As Long ' receives length of buffer after function call
ChDir "\Programs\Test" ' change current directory to C:\Programs\Test
buffer = Space(255) ' make room for buffer to receive the string
numchar = GetFullPathName("datafile.dat", 255, buffer, "") ' put the result string into buffer
buffer = Left(buffer, numchar) ' extract data from the returned string
Debug.Print buffer ' display resulting string
Related Call: GetShortPathName
Category: Files
Back to the index.