Ejemplo n.º 1
0
        public bool CfgLoad()//грузим конфиг
        {
            cfgFInfo = new FileInfo(FileName);
            if (cfgFInfo.Exists)
            {
                cfgFSize = cfgFInfo.Length;
                if (cfgFSize != 0)
                {
                    if (File.Exists(FileName))
                    {
                        FileStream      fileRead        = File.Open(FileName, FileMode.Open);
                        BinaryFormatter binaryFormatter = new BinaryFormatter();
                        try
                        {
                            CfgData2 = (CfgDataStruct2)binaryFormatter.Deserialize(fileRead);
                        }
                        catch (SerializationException se)
                        {
                            MessageBox.Show(String.Format("Нарушена структура файла - {0}", se.Message));
                            fileRead.Close();
                            return(false);
                        }
                        fileRead.Close();
                        DBLoad();

                        //dbSL1.Text = CfgData2.ConStr;
                        ConString     = CfgData2.ConStr;
                        ConStrTB.Text = ConString;

                        dbSLok.Text = ":ok";
                    }
                }
                return(true);
            }
            dbSLok.Text = ":fail";
            return(false);
        }
Ejemplo n.º 2
0
        //грузим конфиг
        public bool CfgLoad()
        {
            cfgFInfo = new FileInfo(FileName);
            if (cfgFInfo.Exists)
            {
                cfgFSize = cfgFInfo.Length;
                if (cfgFSize != 0)
                {
                    if (File.Exists(FileName))
                    {
                        FileStream fileRead = File.Open(FileName, FileMode.Open);
                        BinaryFormatter binaryFormatter = new BinaryFormatter();
                        try
                        {
                            CfgData2 = (CfgDataStruct2) binaryFormatter.Deserialize(fileRead);
                        }
                        catch (SerializationException se)
                        {
                            MessageBox.Show(String.Format("Нарушена структура файла - {0}", se.Message));
                            fileRead.Close();
                            return false;
                        }
                        fileRead.Close();
                        DBLoad();

                        //dbSL1.Text = CfgData2.ConStr;
                        ConString = CfgData2.ConStr;
                        ConStrTB.Text = ConString;

                        dbSLok.Text = ":ok";
                    }

                }
                return true;

            }
            dbSLok.Text = ":fail";
            return false;
        }