通过从comboBox c#中选择项来获取文件 [英] get file by selecting item from comboBox c#

查看:64
本文介绍了通过从comboBox c#中选择项来获取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个comboBox,其中包含:

file1

file2

file3



i想要从comboBox中选择file1上传file1(已经存在)

我该怎么做?

I have a comboBox which contains:
file1
file2
file3

i want to upload file1 (which is existed already) by select file1 from comboBox
how can i do this?

推荐答案

你好

这是代码

Hi
Here is the code
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    string path=comboBox1.SelectedItem.ToString()+".txt";
    string[] myfile;
    if (System.IO.File.Exists(path))
    {
        myfile=System.IO.File.ReadAllLines(path);
    }
}


这篇关于通过从comboBox c#中选择项来获取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆