I am using the GetFinalPathNameByHandle() method to get the target of a reparse point as shown in this answer.
This method returns a path that start with the \\?\ prefix. Using that, I am trying to create a DirectoryInfo with the following line of code:
var myDir = new DirectoryInfo(GetFinalPathName(myPath));
The issue is that I am seeing a really weird behavior depending on where I run the code:
When creating a new console app in VS2019 with .Net framework v4.7.2, the DirectoryInfo is created without issues.
But when I try the same inside a project I'm working on at work, the same line throws an expection:
System.ArgumentException: Illegal characters in path. at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
Both the console app and the work project use the same version of .Net
Is there any project related configuration I am not aware of that changes the behaviour of DirectoryInfo and that may explain why it works in one project but not the other?