C# 如何获取comboBox中的文件,但我需要获取子字符串,以及如何选择文件并将xlsx文件转换为dataGrid 我有一个xlsx文件,文件名是:date\u userId\u UserName;如何分割文件名?我只需要在组合框中查看文件的日期 如果我在组合框中选择了文件名,我需要使用dataGrid打开该文件

C# 如何获取comboBox中的文件,但我需要获取子字符串,以及如何选择文件并将xlsx文件转换为dataGrid 我有一个xlsx文件,文件名是:date\u userId\u UserName;如何分割文件名?我只需要在组合框中查看文件的日期 如果我在组合框中选择了文件名,我需要使用dataGrid打开该文件,c#,C#,代码 public void ComboBoxLoad() { comboBoxFolders.Items.Clear(); string path = AppDomain.CurrentDomain.BaseDirectory+"WorkingHours"; DirectoryInfo d = new DirectoryInfo(path); //i got only the file with th

代码

 public void ComboBoxLoad()
    {
        comboBoxFolders.Items.Clear();
        string path = AppDomain.CurrentDomain.BaseDirectory+"WorkingHours";
        DirectoryInfo d = new DirectoryInfo(path);
        //i got only the file with this userId this is fine :)
        FileInfo[] Files = d.GetFiles("*"+userId+"*");
        //i want to see only the date of the files but i need the files becouse i need to open the files with the data Grid after select
        comboBoxFolders.DataSource = Files;
        comboBoxFolders.DisplayMember = "Name";
    }