Deveel.History.Save C# (CSharp) Method

Save() public static method

Saves the history lines stored in the History into the given file.
public static Save ( string file ) : void
file string The path to the file where to store the /// history lines.
return void
        public static void Save(string file)
        {
            if (File.Exists(file))
                File.Delete(file);

            FileStream fileStream = null;
            try {
                fileStream = new FileStream(file, FileMode.CreateNew, FileAccess.Write, FileShare.None);

                StreamWriter writer = new StreamWriter(fileStream, Encoding.UTF8);
                for (int i = history.Count - 1; i >= 0; i--) {
                    string line = (string) history[i];
                    writer.WriteLine(line);
                }

                writer.Flush();
            } finally {
                if (fileStream != null)
                    fileStream.Close();
            }
        }