public void LoadDatabase(string path = null)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                path = Program.Options.DataFile;
            }

            if (!File.Exists(Program.Options.DataFile))
            {
                var writer = File.CreateText(path);   // Create the file
                writer.Write("{\n}"); writer.Flush(); // Write to the stream and flush it
                writer.Close(); writer.Dispose();     // Close and dispose of the stream
                writer = null;                        // Null the stream
            }

            var        reader     = new StreamReader(path, Encoding.UTF8);
            JsonReader jsonReader = new JsonTextReader(reader);
            // Try to deserialize the stream
            JsonSerializer serializer = new JsonSerializer();
            ImageDataList  imgList    = serializer.Deserialize <ImageDataList> (jsonReader);

            ImageDataList.Images = new ImagesInternal();
            if (imgList != null && imgList.imageList != null)
            {
                ImageDataList.Images.AddRange(imgList.imageList);
            }

            imgList = null;                                      // Null the temporary image list
            jsonReader.Close();                                  // Close the jsonReader
            reader.Close(); reader.Dispose();                    // Close and dispose of the stream
            serializer = null; jsonReader = null; reader = null; // Null the serializer, the reader and the stream
        }
        public void SaveDatabase(string path = null)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                path = Program.Options.DataFile;
            }
            ImageDataList imagesList = new ImageDataList();

            imagesList.imageList = ImageDataList.Images.ToArray();
            JsonSerializer serializer = new JsonSerializer();

            var writer = new StreamWriter(path);

            serializer.Serialize(writer, imagesList, typeof(ImageDataList));
            writer.Flush();
            writer.Close();
        }