【问题标题】:Enabling Long Paths in web application在 Web 应用程序中启用长路径
【发布时间】: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

似乎没有任何效果。任何建议将不胜感激。

【问题讨论】:

  • 请阅读我的回答 here 我解决了这个问题
  • 请阅读我的回答here 我解决了这个问题

标签: asp.net .net web-config app-config .net-4.6.2


【解决方案1】:

所以问题是我将现有应用程序从早期的 .NET(我相信是 4.5.1)版本升级到了 .NET 4.6.2。出于某种原因,当我从一开始就创建了一个针对 .NET 4.6.2 的新 Web 应用程序时,一切都按预期工作。我回去比较了项目文件,没有什么是罪魁祸首。

Win 10 周年更新似乎也引起了问题。如果您来到此页面,您可能还想查看this,因为这也帮助我解决了这个问题。

【讨论】:

    猜你喜欢
    • 2020-05-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-29
    • 2013-07-09
    相关资源
    最近更新 更多