【发布时间】:2018-04-19 04:47:46
【问题描述】:
我正在尝试在 Web 应用程序上启用长路径支持。我遵循了here 的指令,并且能够在一个简单的控制台应用程序上获得长路径。当我将相同的概念转换为 Web 应用程序(使用 web.config 而不是 app.config)时,System.IO 出现以下异常。
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)
我在 Web 应用程序和控制台应用程序上运行的代码行是
Dim dirInfo As New DirectoryInfo("\\fileserver\systems\devFramework\Deploy\DEV\11424495\Rollback_1314799492608780699\Rolloutsuperdupersongpathtestasdfasdfaasdfasasdfasadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasddfasdfasdfasfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdftestadditionalcharacters")
由于两者都使用 System.IO,我不明白问题可能是什么。我还尝试使用
在代码中添加开关 System.AppContext.SetSwitch("Switch.System.IO.UseLegacyPathHandling", False)
System.AppContext.SetSwitch("Switch.System.IO.BlockLongPaths", False)
解释here
似乎没有任何效果。任何建议将不胜感激。
【问题讨论】:
标签: asp.net .net web-config app-config .net-4.6.2