Followed the steps given below to enable long paths and rebooted the machine
Press Win + R keys on your keyboard and type
regedit
then press Enter.
Registry Editor will be opened.Go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Edit LongPathsEnabled and set it to 1.
Press Win + R keys on your keyboard and type
gpedit.msc
then press Enter.
Group Policy Editor will be opened.Go to Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> Filesystem, then enable the Enable Win32 long paths option.
Restart machine.
Executed the below program to check if the file gets created in the already existing folder structure C:\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz
int main()
{
HANDLE h = CreateFileA(
"C:\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\012345678901234567890123456789.txt",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_TEMPORARY,
NULL);
if (h == INVALID_HANDLE_VALUE) { DWORD err = GetLastError(); printf("err %dn", err); getchar(); return 1; }
printf("Created\n");
getchar();
return 0;
}
The above program failed to create the file and produced the following output
err 3
The same program worked in MS Windows 2016
What additional thing needs to be done in Windows 2019 for long paths to work?
Machine details:
Windows Server 2019
Microsoft Windows Server
Version 1809 (OS build 17763.316)