Exemplo n.º 1
0
        /// <summary>
        /// Save CefSharp cache info into JSON file stored in local app data
        /// </summary>
        public static void Save(CefSharpCache cefSharpCache)
        {
            string filepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TwitchBot");
            string filename = "CefSharpCache.json";

            Directory.CreateDirectory(filepath);

            using (StreamWriter file = File.CreateText($"{filepath}\\{filename}"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, cefSharpCache);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load CefSharp cache info from JSON file stored in local app data
        /// </summary>
        public static CefSharpCache Load()
        {
            string filepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TwitchBot");
            string filename = "CefSharpCache.json";

            CefSharpCache cefSharpCache = new CefSharpCache();

            using (StreamReader file = File.OpenText($"{filepath}\\{filename}"))
            {
                JsonSerializer serializer = new JsonSerializer();
                cefSharpCache = (CefSharpCache)serializer.Deserialize(file, typeof(CefSharpCache));
            }

            return(cefSharpCache);
        }