如何创建一个button控件,进行资源选择

创建一个button控件,点击时会自动查询本机文件,点击文件会自动把文件路径加载到TextBox控件里。4

  首先需要添加一个空间openFileDialog

    private void button1_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
//选择文件后,用openFileDialog1的FileName属性获取文件的绝对路径
this.label1.Text = this.openFileDialog1.FileName;
}
 

posted @ 2018-08-02 09:32  风雨踏梦行  阅读(105)  评论(0编辑  收藏  举报