如何在PowerShell中将绝对路径转换为相对路径?

我想在 PowerShell 脚本中将路径转换为相对路径.如何使用 PowerShell 执行此操作?

I'd like to convert a path to a relative path in a PowerShell script. How do I do this using PowerShell?

例如:

Path to convert: c:\documents\mynicefiles\afile.txt
Reference path:  c:\documents
Result:          mynicefiles\afile.txt

Path to convert: c:\documents\myproject1\afile.txt
Reference path:  c:\documents\myproject2
Result:          ..\myproject1\afile.txt



 1 条回答