Skip to main content
GetLongPathNameTransacted function

[Microsoft strongly recommends developers utilize alternative means to achieve your application’s needs. Many scenarios that TxF was developed for can be achieved through simpler and more readily available techniques. Furthermore, TxF may not be available in future versions of Microsoft Windows. For more information, and alternatives to TxF, please see Alternatives to using Transactional NTFS.]

Converts the specified path to its long form as a transacted operation.

To perform this operation without a transaction, use the GetLongPathName function.

For more information about file and path names, see Naming Files, Paths, and Namespaces.


DWORD WINAPI GetLongPathNameTransacted(
  _In_  LPCTSTR lpszShortPath,
  _Out_ LPTSTR  lpszLongPath,
  _In_  DWORD   cchBuffer,
  _In_  HANDLE  hTransaction


lpszShortPath [in]

The path to be converted.

In the ANSI version of this function, the name is limited to MAX_PATH (260) characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming Files, Paths, and Namespaces.

The path must reside on the local computer; otherwise, the function fails and the last error code is set to ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE.

lpszLongPath [out]

A pointer to the buffer to receive the long path.

You can use the same buffer you used for the lpszShortPath parameter.

cchBuffer [in]

The size of the buffer lpszLongPath points to, in TCHARs.

hTransaction [in]

A handle to the transaction. This handle is returned by the CreateTransaction function.

Return value

If the function succeeds, the return value is the length, in TCHARs, of the string copied to lpszLongPath, 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, such as if the file does not exist, the return value is zero. To get extended error information, call GetLastError.


On many file systems, a short file name contains a tilde (~) character. However, not all file systems follow this convention. Therefore, do not assume that you can skip calling GetLongPathNameTransacted if the path does not contain a tilde (~) character.

If a long path is not found, this function returns the name specified in the lpszShortPath parameter in the lpszLongPath parameter.

If the return value is greater than the value specified in cchBuffer, you can call the function again with a buffer that is large enough to hold the path. For an example of this case, see the Example Code section for GetFullPathName.

Note  Although the return value in this case is a length that includes the terminating null character, the return value on success does not include the terminating null character in the count.

It is possible to have access to a file or directory but not have access to some of the parent directories of that file or directory. As a result, GetLongPathNameTransacted may fail when it is unable to query the parent directory of a path component to determine the long name for that component. This check can be skipped for directory components that have file extensions longer than 3 characters, or total lengths longer than 12 characters. For more information, see the Short vs. Long Names section of Naming Files, Paths, and Namespaces.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.


Server Message Block (SMB) 3.0 protocol


SMB 3.0 Transparent Failover (TFO)


SMB 3.0 with Scale-out File Shares (SO)


Cluster Shared Volume File System (CsvFS)


Resilient File System (ReFS)



SMB 3.0 does not support TxF.


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]


WinBase.h (include Windows.h)





Unicode and ANSI names

GetLongPathNameTransactedW (Unicode) and GetLongPathNameTransactedA (ANSI)

See also

File Management Functions
Naming Files, Paths, and Namespaces
Transactional NTFS