Пример #1
0
        public static Shops ReadSettingsFromRegistry()
        {
            Shops       shopToWork = Shops.Bars;
            RegistryKey rk         = null;

            try
            {
                rk = Registry.CurrentUser.OpenSubKey(regKeyName);

                if (rk == null)
                {
                    return(shopToWork);
                }

                shopToWork = (Shops)Shops.Parse(typeof(Shops), (string)rk.GetValue("CurrentShop"));
            }
            catch (Exception)
            {
            }
            finally
            {
                if (rk != null)
                {
                    rk.Close();
                }
            }

            return(shopToWork);
        }
Пример #2
0
        /// <summary>
        /// Чтение данных из файла с настройками
        /// </summary>
        /// <returns>Текущий магазин</returns>
        public static Shops ReadSettingsFromTXT()
        {
            string fileName = Path.Combine(Directory.GetCurrentDirectory(), "settings.txt");

            string[] shop;
            Shops    shopToWork = Shops.Bars;

            try
            {
                shop       = File.ReadAllLines(fileName);
                shopToWork = (Shops)Shops.Parse(typeof(Shops), shop[0]);
            }
            catch (FileNotFoundException)
            {
            }

            return(shopToWork);
        }