private void regCreateSubKey(string apps) { try { proba t = new proba(); string encrypt = t.Encode(textBox2.Text); BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = new FileStream(@apps, FileMode.OpenOrCreate)) { formatter.Serialize(fs, encrypt); } } catch { MessageBox.Show("Ошибка при формировании ключа.\nОбратитесь к системному администратору.", "ФАНЗ", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } try { if (File.Exists(@apps)) { DateTime reg = File.GetCreationTime(apps); string value = Convert.ToString(reg); using (var keySoftware = Registry.LocalMachine.OpenSubKey("Software", true)) { keySoftware.CreateSubKey("Fanz").Close(); RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\Fanz", true); rk.SetValue("RegDate", value, RegistryValueKind.String); label16.Text = "успешно"; } } else { label16.Text = "ошибка"; MessageBox.Show("Ошибка при формировании ключа - файл не создан.\nОбратитесь к системному администратору.", "ФАНЗ", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } catch { try { File.Delete(@apps); } catch { } MessageBox.Show("У вас не хватает прав для установки ключа.\nОбратитесь к системному администратору.", "ФАНЗ", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } }
public static void Main() { proba P = new proba(123); Console.WriteLine("{0}", P.x); }