How to work with long paths on Windows?

Imperatorn johan_forsberg_86 at hotmail.com
Mon Nov 14 10:46:13 UTC 2022


On Monday, 14 November 2022 at 10:44:11 UTC, Imperatorn wrote:
> On Tuesday, 13 September 2022 at 19:54:15 UTC, Preetpal wrote:
>> In Windows 10, Version 1607 (and later), you can [enable long 
>> paths](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry) which bypasses the MAX_PATH limitation for local paths (e.g., C:\Users\you\log.txt). Currently if you iterate over a directory with a file exceeding the MAX_PATH limitation for local paths, an exception is thrown. There is no limitation on Linux (tested using GDC on the Windows Subsystem for Linux) and this issue occurs when using either the LDC2 or DMD compilers on Windows. It's very common to have these sorts of paths if you use [npm](https://www.npmjs.com/).
>>
>> [...]
>
> Have you set longPathAware in the applications manifest?

"If possible, you should embed the application manifest as a 
resource in your application's .exe file or .dll. If you can't do 
that, then you can place the application manifest file in the 
same directory as the .exe or .dll"

"By convention an application manifest should have the same name 
as your app's executable file, with the .manifest extension 
appended to it"

Here's an example

```xml
<application xmlns="urn:schemas-microsoft-com:asm.v3">
     <windowsSettings 
xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
         <ws2:longPathAware>true</ws2:longPathAware>
     </windowsSettings>
</application>
```


More information about the Digitalmars-d-learn mailing list