public static string CreateDirectory(string path) {
string createdBaseFolder = null;
DirectoryInfo di = new DirectoryInfo(path);
while (di.Exists == false) {
createdBaseFolder = di.FullName;
di = di.Parent;
}
if (!Directory.Exists(path)) {
Directory.CreateDirectory(path);
}
return createdBaseFolder;
}