c# creat directory if there isnt one already

how can i create a directory when it cant find one.
i want to create a new directory in the same file where the game.exe and the gameData is. only when it doesnt already exists.
can someone please help me?
thanks!

hi there,

I don’t know if you already tried, but try google;

“c# create directory”

At least I get a first hit that tells me it.

The link also tells that you can do something like this:

if(Directory.Exists(path))
{
     // Do stuff
}

i tried google but i couldn’t find how to save it in the same folder as where the game.exe is

EDIT: how can i give the directory a custom name?

@kelvin-w

Check manual for Application class;

There are:
dataPath → dataPathContains the path to the game data folder (Read Only).
persistentDataPath → Contains the path to a persistent data directory (Read Only).

However, someone else can probably tell if it’s any good idea to use dataPath at all for saving… I think it’s better just use persistent data path…