// Create a subkey underneath this particular registry key. public IRegistryKeyProvider CreateSubKey(String subkey) { String dir = directory + Path.DirectorySeparatorChar + subkey; if (Directory.Exists(dir)) { return(new FileKeyProvider(this, subkey)); } Errno error = DirMethods.CreateDirectory(dir); if (error == Errno.Success || error == Errno.EEXIST) { return(new FileKeyProvider(this, subkey)); } throw new ArgumentException(_("IO_RegistryKeyNotExist")); }
// Create a directory, including parent directories. public static DirectoryInfo CreateDirectory(String path) { // Brubbel 2004-07-01: remove slashes and backslashes at end of path, if not you'll get an exception while (path.EndsWith("/")) { path = path.Remove(path.Length - 1, 1); } while (path.EndsWith("\\")) { path = path.Remove(path.Length - 1, 1); } // Brubbel End. ValidatePath(path); Errno error = DirMethods.CreateDirectory(path); if (error != Errno.Success) { // The path may already exist. if (Exists(path)) { return(new DirectoryInfo(path)); } // Attempt to create the parent directory. String parent = Path.GetDirectoryName(path); if (parent == null) { HandleErrorsDir(error); } CreateDirectory(parent); // Now try creating the child directory again. error = DirMethods.CreateDirectory(path); if (error != Errno.Success) { HandleErrorsDir(error); } } return(new DirectoryInfo(path)); }