Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 加载文件名并在单击文件链接时运行_C#_Winforms_File_System.diagnostics - Fatal编程技术网

C# 加载文件名并在单击文件链接时运行

C# 加载文件名并在单击文件链接时运行,c#,winforms,file,system.diagnostics,C#,Winforms,File,System.diagnostics,我需要加载一些文件名根据用户选择从组合框和运行时,点击文件名 例如: 组合框列表=> 电子的 物理的 当从electrical文件夹中选择electrical load excel文件并从physical folder中选择physical load excel文件时,以及当用户单击文件名run file(运行文件)时 private void cmbMapType_SelectedIndexChanged(object sender, EventArgs e) { cm

我需要加载一些文件名根据用户选择从组合框和运行时,点击文件名

例如:

组合框列表=>

  • 电子的
  • 物理的
当从electrical文件夹中选择electrical load excel文件并从physical folder中选择physical load excel文件时,以及当用户单击文件名run file(运行文件)时

   private void cmbMapType_SelectedIndexChanged(object sender, EventArgs e)
   {
    cmpMapSearchFolder = Application.StartupPath + "\\mv\\" + vo + "\\compact\\" + cmbMapType.SelectedItem.ToString();
            }

            bool cmpMapOk = false;
            foreach (string directoryfilename in Directory.GetFiles(cmpMapSearchFolder, "*.xlsx"))
            {
                cmpMapOk = true;

            }
}
我用什么工具来做这个?怎么做

使用链接标签?

在表单的加载事件中,用字符串列表填充combox

string[] list = {"","electrical","physical"};
cmbMapType.DataSource = list;
并实现ComboBox控件名为SelectedIndexChanged的事件,在该方法中存储文件的链接。好的,以后你可以做很多事情,其中之一是将这些链接存储在列表框中,并实现SelectedValueChanged,在这个方法中启动一个新的过程来打开excel文件:

Process process = new Process();
process.StartInfo.FileName = @"your link to your excel file";
process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
process.Start();

我重申有很多方法可以实现这一点。希望能有所帮助。

请更具体一些,解释更多你想要的。