After a lot of searching on the internet without any success, I'm looking here for some help.
The problem seems to be quiet simple, but unfortunately I'm not able to solve it.
I want to change the default-application to open .txt-files. For example instead of using notepad I want to use Wordpad which is located at C:\Program Files\Windows NT\Accessories\wordpad.exe
So I've tried to change the registry at: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithProgids
with no success.
I've also found a solution which tries to change the group policy. This code looks like:
string tempFile = Path.GetTempFileName();
string xmlFile = tempFile.Replace(".tmp", ".xml");
File.Move(tempFile, xmlFile);
XDocument document = new XDocument(new XElement("DefaultAssociations",
new XElement("Association",
new XAttribute("Identifier", ".txt"),
new XAttribute("ProgId", "txtFile"),
new XAttribute("ApplicationName", "Editor"))));
document.Save(xmlFile);
ComputerGroupPolicyObject.SetPolicySetting(@"HKLM\Software\Policies\Microsoft\Windows\System!DefaultAssociationsConfiguration",
xmlFile, RegistryValueKind.String);
But this also doesn't work.
I also tried to use the command-line with ftype
but that also didn't work.
Can anybody tell me how to change the assoziated application for a given filetype?