public void Load(string fileName) { this.New(); this.FileName = fileName; string fileExtension = Path.GetExtension(fileName).ToLower(); try { switch (fileExtension) { case ".xml": case ".resx": using (ResXResourceReader reader = new ResXResourceReader(fileName)) { this.BeginUpdate(); Hashtable resources = new Hashtable(); IDictionaryEnumerator enumerator = reader.GetEnumerator(); while (enumerator.MoveNext()) { string name = (string) enumerator.Key; object value = enumerator.Value; if (!resources.Contains(name)) { this.AddResource(name, value); resources.Add(name, value); } } this.EndUpdate(); } break; case ".resources": using (FileStream stream = File.OpenRead(fileName)) { this.BeginUpdate(); using (ResourceReader reader = new ResourceReader(stream)) { Hashtable resources = new Hashtable(); IDictionaryEnumerator enumerator = reader.GetEnumerator(); while (enumerator.MoveNext()) { string name = (string)enumerator.Key; object value = enumerator.Value; if (!resources.Contains(name)) { this.AddResource(name, value); resources.Add(name, value); } } } this.EndUpdate(); } break; case ".txt": using (StreamReader reader = File.OpenText(fileName)) { this.BeginUpdate(); Hashtable resources = new Hashtable(); while (reader.Peek() != -1) { string line = reader.ReadLine(); line = line.TrimStart(); if (!line.StartsWith(";")) { int index = line.IndexOf("="); if (index != -1) { string name = line.Substring(0, index); string value = line.Substring(index + 1); name = name.Trim(); if (!resources.Contains(name)) { this.AddResource(name, value); resources.Add(name, value); } } } } this.EndUpdate(); } break; default: MessageBox.Show(this, "Unknown resource file format.", StringTable.GetString("ApplicationName")); break; } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } this.IsDirty = false; }