0

This my static Temp directory.

public static readonly string Temp = Environment.GetEnvironmentVariable("TEMP") + "\\Quince\\";

Is it possible to check it in one line if directory is not, create it.

Quince
  • 144
  • 11
  • 2
    Of course it is, but why does it have to be a 'oneliner' ? Also it is not clear if the check should happen only once, or every time the variable is accessed? – CSharpie Mar 31 '20 at 15:21
  • Directory.Exists("Folder Name") – jdweng Mar 31 '20 at 15:24
  • 1
    In most cases, you should not be using `Environment.GetEnvironmentVariable("TEMP")` to get the temp path. [Use `System.IO.Path.GetTempPath()` instead](https://stackoverflow.com/a/944533/3648487). – Patrick Tucci Mar 31 '20 at 15:25
  • And use [Path.Combine](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine) instead of string concat – Hans Kesting Mar 31 '20 at 15:30

0 Answers0