public void load(string file) { try { using (System.IO.StreamReader sr = new System.IO.StreamReader(file)) { parse(sr); } } catch (System.IO.IOException ex) { FileException fe = new FileException(ex); fe.path = file; throw fe; } }
public void load(string file) { #if NET45 if (file.StartsWith("HKCU\\", StringComparison.Ordinal) || file.StartsWith("HKLM\\", StringComparison.Ordinal)) { RegistryKey key = file.StartsWith("HKCU\\", StringComparison.Ordinal) ? Registry.CurrentUser : Registry.LocalMachine; RegistryKey iceKey = key.OpenSubKey(file.Substring(file.IndexOf("\\") + 1)); if (iceKey == null) { Ice.InitializationException ex = new Ice.InitializationException(); ex.reason = "Could not open Windows registry key `" + file + "'"; throw ex; } foreach (string propKey in iceKey.GetValueNames()) { RegistryValueKind kind = iceKey.GetValueKind(propKey); if (kind == RegistryValueKind.String || kind == RegistryValueKind.ExpandString) { setProperty(propKey, iceKey.GetValue(propKey).ToString()); } } } else { #endif try { using (System.IO.StreamReader sr = new System.IO.StreamReader(file)) { parse(sr); } } catch (System.IO.IOException ex) { FileException fe = new FileException(ex); fe.path = file; throw fe; } #if NET45 } #endif }