Esempio n. 1
0
        /// <summary>
        /// Loads account from file
        /// </summary>
        /// <param name="fp">File path</param>
        /// <returns>The account from <paramref name="fp"/></returns>
        public static Account FromFile(string fp)
        {
            switch (Path.GetExtension(fp))
            {
            case ".cna":
                return(LoadAlt(fp));

            case ".cne":
            {
                var ax = new InputDialog();
                switch (Settings.Default.Lang.Name)
                {
                case "de-DE":
                    ax.MainInstruction = de_DE.Account_Crypted_TypePassword;
                    break;

                case "fr-FR":
                    ax.MainInstruction = fr_FR.Account_Crypted_TypePassword;
                    break;

                case "vi-VN":
                    ax.MainInstruction = vi_VN.Account_Crypted_TypePassword;
                    break;

                default:         //case "en-US":
                    ax.MainInstruction = en_US.Account_Crypted_TypePassword;
                    break;
                }

                if (ax.ShowDialog() == DialogResult.OK)
                {
                    var aeee = FromXmlCode(CryptorEngine.Decrypt(File.ReadAllText(fp), ax.Input, true), fp);
                    aeee.Encrypted = true;
                    return(aeee);
                }
            }
            break;

            case ".cnsql":
                return(FromSQLite(fp));
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Saves the account
        /// </summary>
        public void Save()
        {
            if (_fp == "")
            {
                return;
            }

            if (Path.GetExtension(_fp) == ".cnsql")
            {
                SaveSQLite(_fp);
            }
            else
            {
                if (!Encrypted)
                {
                    ToXml(this, _fp);
                }
                else
                {
                    File.WriteAllText(_fp, CryptorEngine.Encrypt(ToXml(this, _fp, false).ToString(), Pass, true));
                }
            }
        }