Deb Deb - 1 year ago 82
ASP.NET (C#) Question

Strange Path.GetFullPath different behaviour between .Net 4.6.1 & 4.6.2 for file path ending with 0x85 char (windows 8)

I am not able to find the reason for this strange Path.GetFullPath behaviour between .Net 4.6.1 & 4.6.2 for file path ending with 0x85 char (windows 8).


var _originalPath = @"D:\user\/web.config." + (char) 0x85;
string _fullPath = Path.GetFullPath(_originalPath);

Using 4.6.1 this returns correctly:
_fullPath = D:\user\web.config

However if I switch to 4.6.2 then it becomes:
_fullPath = D:\user\web.config.

(See the extra dot remains!!) :(

I am missing something but am not able to figure out what.

Can someone knowledgeable in this area please help explain/solve this??

namespace ConsoleApplication1
public class Program
internal static void Main(string[] args)

var _originalPath = @"D:\user\/web.config." + (char) 0x85;
string _fullPath = Path.GetFullPath(_originalPath);


Answer Source

I'm not able to repro this, but this change in behavior could be related to the support for long filenames that has been added in .NET 4.6.2. According to the release notes, you can always switch back to the earlier behavior by putting the following into your app.config:

<?xml version="1.0" encoding="utf-8" ?>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    <AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=true" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download