2

I am attempting to enable long path support on a web application. I have followed the instruction here and was able to get long paths working on a simple console app. When I translate the same concept to a web application (Using the web.config instead of the app.config) System.IO blows up with the following exception.

at System.IO.PathHelper.GetFullPathName() at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) at System.IO.Path.GetFullPathInternal(String path) at System.IO.DirectoryInfo.Init(String path, Boolean checkHost)

The line of code that I am running both on the web app and console app is

Dim dirInfo As New DirectoryInfo("\\fileserver\systems\devFramework\Deploy\DEV\11424495\Rollback_1314799492608780699\Rolloutsuperdupersongpathtestasdfasdfaasdfasasdfasadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasddfasdfasdfasfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdftestadditionalcharacters")

Since both are using System.IO I dont understand what the issue could be. I have also tried adding the switches in code using

        System.AppContext.SetSwitch("Switch.System.IO.UseLegacyPathHandling", False)
    System.AppContext.SetSwitch("Switch.System.IO.BlockLongPaths", False)

as explained here

Nothing seems to work. Any advice would be greatly appreciated.

CW2272
  • 183
  • 1
  • 10
  • Please read my answer [here](https://stackoverflow.com/questions/44888844/error-using-long-paths-in-net-4-7/55206051#55206051) where I resolved this – Tomáš Sýkora Mar 17 '19 at 10:36
  • Please read my answer [here](https://stackoverflow.com/questions/44888844/error-using-long-paths-in-net-4-7/55206051#55206051) where I resolved this – Tomáš Sýkora Mar 17 '19 at 10:39

1 Answers1

2

So the issue was I upgraded an existing application from an earlier .NET (4.5.1 I believe) version to .NET 4.6.2. For some reason when I created a new web application targeting .NET 4.6.2 from the get go everything worked as expected. I went back and diffed the project files and nothing stood out as the culprit.

It also seems the Win 10 Anniversary update is also causing issues. If you come to this page, you also may want to check out this as that helped me solve this issue as well.

CW2272
  • 183
  • 1
  • 10