[System.IO.Path]::GetFullPath with a relative path is not honoring the current working directory as documented
See original GitHub issueSteps to reproduce
# CD to user home directory then call GetFullPath with a relative path
cd; [System.IO.Path]::GetFullPath("path")
Expected behavior
Per the documentation for GetFullPath and the behavior in Windows PowerShell:
C:\Users\<USER>\path
Actual behavior
A path relative to "c:\windows\system32" is returned regardless of the current working directory.
C:\WINDOWS\system32\path
Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.2
PSEdition Core
GitCommitId 7.0.0-preview.2
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Path.GetFullPath Method (System.IO)
If path is a relative path, this overload returns a fully qualified path that can be based on the current drive and current...
Read more >How to get relative path from absolute path
So I would prefer to show the file path relative to the assembly/exe directory. For example, the assembly resides at C:\Program Files\Dummy ...
Read more >C# relative, absolute path - Microsoft Q&A
Hello, why is not workling? I use relative path. ToXMLFile($@"..\..\Data\Orders\{CurrentOrderSerials.OrderId}.xml"); public static void ...
Read more >Relative file paths, and the .NET adapter. - NI Community
The current working directory is set by the open file dialog when you browse to a specific directory and by many other things...
Read more >Type: System.IO.Path
A path can contain absolute or relative location information. Absolute paths fully specify a location: the file or directory can be uniquely identified ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That works on PS 5.1 . @hunandy14 ^^^
Ok. I see there is an open doc issue for this. Would be nice to see this captured somewhere discoverable as while always converting to absolute paths works that’s not obvious or natural if you haven’t been burned by this before.