I have set Enable Win32 Long Paths
in the Local Group Policy Editor to Enabled
and restarted the computer.
And here's the code:
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
for (int i = 0; i < 10; i++)
path += "\\" + new string('z', 200);
Directory.CreateDirectory(path);
I'm getting the error:
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'C:\Users...\Desktop\zzzzzzzzzz...
(Which is actually a strange error message.)
app.config already has:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
More info (probably not important)
I tried adding as mentioned in this post and elsewhere (though as pointed out in the comments it's not needed when using .net 4.7) in app.config under configuration
:
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false" />
</runtime>
Still same error.
If I only use one zzzzzz...
it creates it on the desktop with no error.
I'm using VS2017, Windows 10. I tried Winforms and WPF.
UseLegacyPathHandling
set to false. – EctomorphEnable Win32 Long Paths
in the Local Group Policy Editor toEnabled
. I'm still seeing the same error. Any ideas? – Hedgcock<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
. – Hedgcock4.0
isn't quite the same asversion=".NETFramework,Version=v4.6.2
(or so I'd guess, not really sure) – VoussoirDirectoryInfo
instead, to create the Directory. Still no go. – Hedgcock