Skip to content

Breaking change: The behaviour of System.IO.Path.GetFullPath has changed for some reserved filenames. #78834

@tg73

Description

@tg73

Description

Compare the two invocations of System.IO.Path.GetFullPath( "COM3.1.txt" ) detailed below. One returns \\.\COM3, the other returns C:\COM3.1.txt. The older system returns \\.\COM3 as our code expects, the newer system does not. This is a breaking change. I am not able to determine exactly what is responsible for this change - it could be the netfx version, the OS version, or some windows update. The filename COM3.1.txt is used as an example, but other variations are affected in the same way, for example COM3.txt, COM1.txt, PRN.txt.

Both sample systems are x64.

On a sample Win 10 system:

PS C:\> [io.path]::getfullpath("COM3.1.txt")
\\.\COM3
PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\> [Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.19045.0 Microsoft Windows NT 10.0.19045.0

PS C:\> (Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Version
4.8.04084
PS C:\> (Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release
528372

On a sample Win 11 system:

PS C:\> [io.path]::getfullpath("COM3.1.txt")
C:\COM3.1.txt
PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\> [Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.22621.0 Microsoft Windows NT 10.0.22621.0

PS C:\> (Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Version
4.8.09032
PS C:\> (Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release
533320

Reproduction Steps

See above.

Expected behavior

System.IO.Path.GetFullPath( "COM3.1.txt" ) should return \\.\COM3, as it has done historically.

Actual behavior

System.IO.Path.GetFullPath( "COM3.1.txt" ) returns C:\COM3.1.txt on some likely more-modern or more-updated environments.

Regression?

Yes, it is a regression.

Known Workarounds

No response

Configuration

See description.

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOdocumentationDocumentation bug or enhancement, does not impact product or test code

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions