如何通过我的C#程序打开计算机上的所有*.xml文件?

如何通过我的C#程序打开计算机上的所有*.xml文件?,c#,winforms,installation,C#,Winforms,Installation,我制作了一个C#程序来打开和显示xml文件 如何(在我的程序安装中)使所有*.xml文件 在我的电脑里会用我的程序打开吗 提前感谢如中所述,您需要更改用户计算机上注册表项HKEY\U CLASSES\U ROOT\xmlfile\shell\open\command的值 这可以通过以下代码编程实现(未测试): 我认为他想要一种在硬盘上搜索所有xml文件的方法,这样他就可以在某种树中管理这些文件,以便于打开和关闭 你可以做类似的事情 void RecursiveDirectorySearch

我制作了一个C#程序来打开和显示xml文件

如何(在我的程序安装中)使所有*.xml文件

在我的电脑里会用我的程序打开吗

提前感谢

如中所述,您需要更改用户计算机上注册表项
HKEY\U CLASSES\U ROOT\xmlfile\shell\open\command
的值

这可以通过以下代码编程实现(未测试):


我认为他想要一种在硬盘上搜索所有xml文件的方法,这样他就可以在某种树中管理这些文件,以便于打开和关闭

你可以做类似的事情

   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);
            }
        }

请参阅是否希望以编程方式执行此操作(安装应用程序时等)?或者只是在你的计算机上手动执行一次?可能是
   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);
            }
        }