static void GenerateKey(UserState userState, string accountname, string protocol, string filename) { if (File.Exists(filename)) { userState.ReadPrivateKey(filename); } else { Console.WriteLine("Generating key, this might take a while, please wait"); userState.GeneratePrivateKey(filename, accountname, protocol); } }