I've got an environment variable set that points to a specific folder (call it MYFOLDER for example). When typing in %MYFOLDER%\SubFolder
into windows explorer the subfolder appears. However, when I pass SelectedPath = @"%MYFOLDER%\SubFolder";
to a FolderBrowserDialog
, it doesn't work.
I tried using Path.GetFullPath(..)
, but this seems to return the bin folder of the executable (while debugging in VS) with %MYFOLDER% on the end, instead of the path I'd expect.
Anyone know how to get it to use the environment variable properly?
To add a path to the PATH environment variableIn the System dialog box, click Advanced system settings. On the Advanced tab of the System Properties dialog box, click Environment Variables. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.
You can put environment variables in your properties file, but Java will not automatically recognise them as environment variables and therefore will not resolve them. In order to do this you will have to parse the values and resolve any environment variables you find.
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.
Expand it first:
string path = Environment.ExpandEnvironmentVariables(value);
http://msdn.microsoft.com/en-us/library/system.environment.expandenvironmentvariables.aspx
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