using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ParticleFramework.Data { class Properties { #region Fields public System.Collections.Hashtable props = new System.Collections.Hashtable(); #endregion public Boolean Load(string filename) { try { FileStream file = File.Open(filename, FileMode.Open); UTF8Encoding temp = new UTF8Encoding(true); string fileContents = ""; byte[] b = new byte[1024]; while (file.Read(b, 0, b.Length) > 0) { fileContents += temp.GetString(b); } string[] lineSplit = fileContents.Split((char)10); for(int i = 0; i < lineSplit.Length; i++) { props.Add(lineSplit[i].Split('=')[0], lineSplit[i].Split('=')[1]); } return true; } catch { Console.WriteLine("Unable to load properties file: " + filename); return false; } } public string Get(string name) { if (props.ContainsKey(name)) { return props[name].ToString(); } else { Console.WriteLine("Property " + name + " not defined!"); return ""; } } } }