Powershell: resolve path that might not exist?

Posted by Eamon Nerbonne on Stack Overflow See other posts from Stack Overflow or by Eamon Nerbonne
Published on 2010-06-14T15:09:54Z Indexed on 2010/06/14 15:12 UTC
Read the original article Hit count: 411

Filed under:

I'm trying to process a list of files that may or may not be up to date and may or may not yet exist. In doing so, I need to resolve the full path of an item, even though the item may be specified with relative paths. However, Resolve-Path prints and error when used with a non-existant file.

For example, What's the simplest, cleanest way to resolve ".\newdir\newfile.txt" to "C:\Current\Working\Directory\newdir\newfile.txt" in Powershell?

Note that System.IO.Path's static method use with the process's working directory - which isn't the powershell current location.

© Stack Overflow or respective owner

Related posts about powershell