static DirectoryInfo CreateDirectoriesInternal(string path) { #if !MOBILE if (SecurityManager.SecurityEnabled) { new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.Write, path).Demand(); } #endif DirectoryInfo info = new DirectoryInfo(path, true); if (info.Parent != null && !info.Parent.Exists) { info.Parent.Create(); } MonoIOError error; if (!MonoIO.CreateDirectory(info.FullName, out error)) { // LAMESPEC: 1.1 and 1.2alpha allow CreateDirectory on a file path. // So CreateDirectory ("/tmp/somefile") will succeed if 'somefile' is // not a directory. However, 1.0 will throw an exception. // We behave like 1.0 here (emulating 1.1-like behavior is just a matter // of comparing error to ERROR_FILE_EXISTS, but it's lame to do: // DirectoryInfo di = Directory.CreateDirectory (something); // and having di.Exists return false afterwards. // I hope we don't break anyone's code, as they should be catching // the exception anyway. if (error != MonoIOError.ERROR_ALREADY_EXISTS && error != MonoIOError.ERROR_FILE_EXISTS) { throw MonoIO.GetException(path, error); } } return(info); }