【发布时间】:2021-05-26 02:29:24
【问题描述】:
我的.net 4.5.1 WPF 应用程序需要长路径支持。
App.config 中的此设置有效(支持长路径):
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false" />
</runtime>
所以我尝试在代码中设置,但它并没有改变行为:
public App()
{
// returns correct type:
Type type = Type.GetType("System.AppContext");
if (type != null)
{
// returns correct switch:
MethodInfo setSwitch = type.GetMethod("SetSwitch", BindingFlags.Public | BindingFlags.Static);
setSwitch.Invoke(null, new object[] { "Switch.System.IO.UseLegacyPathHandling", false });
setSwitch.Invoke(null, new object[] { "Switch.System.IO.BlockLongPaths", false });
}
}
.net 4.5.1 不支持“代码隐藏设置”吗?
【问题讨论】:
标签: c# wpf .net-4.5 app-config