Quantcast
Channel: whileloop » code
Viewing all articles
Browse latest Browse all 10

ensuring a Directory exists in C#

$
0
0

Often we need to ensure a Directory exists before we reference or use it. This is a little method that does this for you. Nothing complicated, but if you need to check that 2 or more directories exist, this will save you lines of code:

private static void EnsureDirectoryExists(string dir) {	
	if (!Directory.Exists(dir)) {
		Directory.CreateDirectory(dir);
	}
}


Viewing all articles
Browse latest Browse all 10

Trending Articles