public static string GetLicenseValue() { string ret_license_value = string.Empty; InputBox obj = new InputBox(); { string filename = (Path.Combine(Environment.CurrentDirectory, @"SDKLicense.txt")); if (File.Exists(filename)) { using (StreamReader sr = File.OpenText(filename)) { ret_license_value = sr.ReadLine().Trim(); } } else { string value = string.Empty; bool loop_flag = false; string msg = string.Empty; DialogResult diagRes; do { if (!loop_flag) { msg = "SDK License file not found." + Environment.NewLine + "Please enter the SDK license key."; } else { if (ret_license_value.Equals(string.Empty)) { msg = "The textbox cannot be empty." + Environment.NewLine + "Please enter the SDK license key."; } else { msg = "The license key should be 16 characters long." + Environment.NewLine + "Please enter the correct SDK license key."; } } diagRes = obj.Show(msg, ref value); if (diagRes == DialogResult.OK) { loop_flag = true; ret_license_value = value.Trim(); } else { obj.FormClose(); Application.Exit(); } }while ((ret_license_value.Equals(string.Empty)) || (ret_license_value.Length != 16)); FileStream fs = File.Open(filename, FileMode.CreateNew, FileAccess.Write); StreamWriter sw = null; sw = new StreamWriter(fs, System.Text.Encoding.UTF8); sw.WriteLine(ret_license_value); sw.Close(); } } return(ret_license_value); }