Why wouldn't a folder exist after you create it?

c#

Solution

The value in `folder.Exists` is cached. I would suggest doing this check:

var doesItExists = Directory.Exists(folder.FullName);

Or you could call `folder.Refresh()` to update the cache before checking if the directory exists after creating it. See this previous answer.

Problem

This doesn't seem to make sense, so I'm obviously doing something wrong: ``` DirectoryInfo folder = new DirectoryInfo(Environment.CurrentDirectory + @"\Test"); if (folder.Exists == false) { folder.Create(); var doesItExists = folder.Exists; } ``` Creates a folder if it doesn't exist. Except `doesItExists` is always false. Why would it be false if I just created it?

Original source

Related problems