When you have a project that explicitly targets the .NET Framework 4.6.2 or that disables the AppContext switch Switch.System.IO.UseLegacyPathHandling, Path.GetDirectoryName() and Path.GetPathRoot() throw an invalid path exception when they are passed a URI (such as http://).
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.