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>
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for