The following code works on debug builds, it works on release builds and it works when manually executing a published executable in the published dir (eg "..\Application Files\WindowsApp1_1_0_1_0\WindowsApp1.exe").
However, when running the .application to execute the published application, it throws the following error: "Illegal characters in path".
I am using the '\\?\' notation because my application needs to support long file names. I believe this notation is supported from framework 4.7.2.
For Each f As String In IO.Directory.GetFiles("\\?\c:\")
Console.WriteLine(f)
Next
Environment: VS 2022 publishing a winforms vb app ( framework 4.8).
Why would this code work perfectly in all cases except when running a published .application file and how do I work around this issue while still being able to use long file names on framework 4.8?