Deveel.History.Load C# (CSharp) Method

Load() public static method

Loads a set of history lines from a given file.
public static Load ( string file ) : void
file string The path to the file containing the history /// lines to load.
return void
        public static void Load(string file)
        {
            if (!File.Exists(file))
                throw new InvalidOperationException();

            FileStream fileStream = null;
            try {
                fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
                StreamReader reader = new StreamReader(fileStream, Encoding.UTF8);

                ClearHistory();

                string line;
                while ((line = reader.ReadLine()) != null)
                    AddHistory(line);
            } finally {
                if (fileStream != null)
                    fileStream.Close();
            }
        }