Exemplo n.º 1
0
        private void M_AButton_Click(object sender, EventArgs e)
        {
            string APIKey = this.m_KTextBox.Text.Trim();
            bool   valid  = true;

            for (int i = 0; i < APIKey.Length; i++)
            {
                if (APIKey[i] == 9 || APIKey[i] == 13 ||
                    APIKey[i] == 32)
                {
                    valid = false;
                    break;
                }
            }
            if (!valid)
            {
                Error.Reason(Errors.CReason);
                return;
            }
            RegConfig regConfig = new RegConfig();

            regConfig.SetAPIKey(APIKey);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 2
0
        private void M_AButton_Click(object sender, EventArgs e)
        {
            FileInfo fileInfo = new FileInfo(this.m_FTextBox.Text);

            if (!fileInfo.Exists)
            {
                Error.Reason(Errors.AReason);
                return;
            }
            try
            {
                FileStream fileStream = new FileStream(fileInfo.FullName,
                                                       FileMode.Open, FileAccess.Read);
                int length = (int)fileStream.Length;
                if (length >= 100)
                {
                    Error.Reason(Errors.BReason);
                    return;
                }
                byte[] array = new byte[100];
                fileStream.Read(array, 0, length);
                fileStream.Close();
                string APIKey = Encoding.ASCII.GetString(array).Trim();
                bool   valid  = true;
                for (int i = 0; i < APIKey.Length; i++)
                {
                    if (APIKey[i] == 9 || APIKey[i] == 13 ||
                        APIKey[i] == 32)
                    {
                        valid = false;
                        break;
                    }
                }
                if (!valid)
                {
                    Error.Reason(Errors.CReason);
                    return;
                }
                RegConfig regConfing = new RegConfig();
                regConfing.SetAPIKey(APIKey);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (IOException except)
            {
                Error.Reason(except.Message);
            }
        }