i made C# program that open and show xml files.
how to make (on my program installation) that all *.xml files
that in my computer will opened with my program ?
thanks in advance
i made C# program that open and show xml files.
how to make (on my program installation) that all *.xml files
that in my computer will opened with my program ?
thanks in advance
As detailed in this question, you need to change the value of the registry key HKEY_CLASSES_ROOT\xmlfile\shell\open\command
on the user's machine.
This could be achieved programatically by code such as (untested):
// Get App Executable path
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
RegistryKey rkShellOpen = Registry.ClassesRoot.OpenSubKey(@"xmlfile\shell\open", true);
rkShellOpen.SetValue("command", appPath);
I think he is wanting a way to search the hard drive for all xml files, so that he can then manage them in some sort of tree for easy opening and closing.
You could do something similar to this...
void RecursiveDirectorySearch(string sDir, string patternToMatch)
{
// Where sDir would be the drive you want to search, I.E. "C:\"
// Where patternToMatch has the extension, I.E. ".xml"
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, txtFile.Text))
{
if(f.Contains(patternToMatch)
{
lstFilesFound.Items.Add(f);
}
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}