5

I have path variable which I got from my appsettings:

var path="%TEMP%\myapplication\data";

I am trying to use it in Directory.CreateDirectory(path) method. But I got new folder in my application bin folder instead of C:\Users\Evgeny\AppData\Local\Temp\myapplication\data.

Should I replace %TEMP% manually?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ievgen
  • 4,261
  • 7
  • 75
  • 124

1 Answers1

11

Use System.Environment.ExpandEnvironmentVariables like so:

String concretePath = Environment.ExpandEnvironmentVariables(@"%TEMP%\myapplication\data");
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Dai
  • 141,631
  • 28
  • 261
  • 374