How to write C programs that can use long > 260 pathnames?

Robert Benaroya Suspended 20 Reputation points
2024-08-19T11:32:53.25+00:00

Hi,

I have enabled Long Paths in the Group Policy Editor, rebooted, and tested this code:

LPCWSTR fileEXT;

fileEXT = L"D:\m1\pro\long\12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________12________.txt";

//fileEXT = L"D:\m1\pro\long\12________12_";

HANDLE hnd = CreateFileW(fileEXT, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

if (hnd == INVALID_HANDLE_VALUE)

That works with the short name commented out here, but not with the long one.

What am I doing wrong?

Note: that also fails using CreateFileW()

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,751 questions
{count} votes

Accepted answer
  1. RLWA32 45,691 Reputation points
    2024-08-19T11:46:51.1133333+00:00

    In addition to configuring windows for long path support you must also have your application opt-in to the feature by providing a manifest that does so. See the documentation at Maximum Path Length Limitation

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.