I have developed a text editor with WPF C #. I want the user to have the possibility to make this text editor the standard software for text files. I researched that it needs to go through the Windows registry, but I do not know how.
I tried this, but it does not work:
private void standard programs for text files ()
{
RegistryKey vRegist;
RegistryKey vKey;
vRegist = Registry.ClassesRoot.OpenSubKey ("", true);
vKey = vRegist.CreateSubKey (".txt");
vKey.SetValue ("", "textfile");
vKey = vRegist.CreateSubKey ("textfile");
vKey.SetValue ("", "text file");
vKey = vRegist.CreateSubKey (@ "textfile \ DefaultIcon");
vKey.SetValue ("", System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly (). GetName (). CodeBase) + ".0");
vKey = vRegist.CreateSubKey (@ "textfile \ shell \ open \ command");
vKey.SetValue ("", System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly (). GetName (). CodeBase) + "% 1");
}
But it does not work.
I want a code sample.