Ejemplo n.º 1
0
        public bool SaveSQLProfileList(string strFileName)
        {
            string strDataPath = GetAssemblyDirectory(); //Changed to Installed Directory TOM

            strDataPath += "\\";

            Stream stream = null;

            try
            {
                //Opens a file and serializes the object into it in binary format.
                stream = File.Open(strDataPath + strFileName, FileMode.Create);
                //SoapFormatter^ formatter = gcnew SoapFormatter;

                XmlSerializer formatter = new XmlSerializer(SQLProfileListManager.GetType());

                //BinaryFormatter* formatter = new BinaryFormatter();
                formatter.Serialize(stream, SQLProfileListManager);
                stream.Close();

                return(true);
            }
            catch (Exception)
            {
                //System::Windows::Forms::MessageBox::Show(Ex->Message);
                if (stream != null)
                {
                    stream.Close();
                }
                return(false);
            }
            return(false);
        }
Ejemplo n.º 2
0
        private bool LoadSQLSelectionProfileList(string strFileName)
        {
            //System::String^ strDataPath=Environment::GetFolderPath(Environment::SpecialFolder::ApplicationData);
            string strDataPath = GetAssemblyDirectory(); //Changed to Installed Directory TOM

            strDataPath += "\\";

            Stream stream = null;

            try
            {
                //SoapFormatter^ formatter = gcnew SoapFormatter;
                XmlSerializer formatter = new XmlSerializer(SQLProfileListManager.GetType());

                stream = System.IO.File.Open(strDataPath + strFileName, System.IO.FileMode.Open);
                //formatter = new BinaryFormatter();
                SQLProfileListManager = (SQLProfileManager)formatter.Deserialize(stream);
                stream.Close();

                return(true);
            }
            catch (Exception)
            {
                //System::Windows::Forms::MessageBox::Show(Ex->Message);
                if (stream != null)
                {
                    stream.Close();
                }
                return(false);
            }
        }