In my console app I get the list of all installed programs which then displays in the console. But how can I save that to a text file?
This is my code I am using
private static void GetInstalledApps32()
{
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
Console.WriteLine(sk.GetValue("DisplayName"));
}
catch (Exception ex)
{
}
}
}
}
}
I have searched for solutions but it then only writes one line instead of all the lines.
Thanks