I am trying to read in from a file where a folder path is specified using environment variable shortcuts, like the following:
source dest
filename.ext %programfiles(x86)%\FolderName\
I get the following error when trying to use Path.Combine() to concatenate this with a filename:
"Could not find a part of the path %programfiles(x86)%\FolderName\filename.ext"
Do I have to parse environment variables (like %programfiles(x86)% and %appdata%) out and manually replace them, or is there a another way to have these resolved? Seems like a common use case for copying files, e.g. patching.
You can set default values for environment variables using a .env file, which Compose automatically looks for in project directory (parent folder of your Compose file). Values set in the shell environment override those set in the .env file.
The PATH environment variable is an important security control. It specifies the directories to be searched to find a command. The default systemwide PATH value is specified in the /etc/profile file, and each user normally has a PATH value in the user's $HOME/.
Combines two strings into a path.
Use this to get the environment variable path
var path = Environment.ExpandEnvironmentVariables(value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With