Mitigation: Path Colon Checks
Starting with apps that target the .NET Framework 4.6.2, a number of changes were made to support previously unsupported paths (both in terms of length and format). In particular, checks for the proper drive separator syntax (the colon) were made more correct.
Impact
These changes block some URI paths the Path.GetDirectoryName and Path.GetPathRoot methods previously supported.
Mitigation
To work around the problem of a previously acceptable path that is no longer supported by the Path.GetDirectoryName and Path.GetPathRoot methods, you can do the following:
Manually remove the scheme from a URL. For example, remove
file://
from a URL.Pass the URI to a Uri constructor, and retrieve the value of the Uri.LocalPath property.
Opt out of the new path normalization by setting the
Switch.System.IO.UseLegacyPathHandling
AppContext switch totrue
.<runtime> <AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=true" /> </runtime>