private static void CreateDatabase() { Console.WriteLine(string.Format("Creating the '{0}' database file.", cdbFilePath)); using (CdbWriter cdbWriter = new CdbWriter(cdbFilePath)) { foreach (KeyValuePair <string, string> item in data) { Console.WriteLine(string.Format("Adding item '{0}' to the database. Value = {1}", item.Key, item.Value)); byte[] key = EncodeKey(item.Key); byte[] value = EncodeValue(item.Value); cdbWriter.Add(key, value); } cdbWriter.Finish(); } }
static void Main(string[] args) { /* Display a usage message if we didn't get the correct number * of arguments. */ if (args.Length < 2) { Console.WriteLine("CDB Maker: usage: ConstantDatabase.Maker.exe cdb_file temp_file [ignoreCdb]"); return; } /* Decode our arguments. */ string cdbFile = args[0]; string tempFile = args[1]; /* Load the ignoreCdb if requested. */ CdbReader ignoreCdb = null; if (args.Length > 3) { try { ignoreCdb = new CdbReader(args[2]); } catch (IOException ioException) { Console.WriteLine("Couldn't load `ignore' CDB file: " + ioException); } } /* Create the CDB file. */ try { CdbWriter.Make(Console.OpenStandardInput(), cdbFile, tempFile, ignoreCdb); } catch (IOException ioException) { Console.WriteLine("Couldn't create CDB file: " + ioException); } }