winfrom 通过按钮选择文件

 private void ExcelBtn_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = " Excel文件|*.xls";
                if (ofd.ShowDialog() == DialogResult.OK)
                {               
                    this.ExcelText.Text = ofd.FileName;
                }
            }
        }

 //选择保存文件路径
        private void PutBtn_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.Filter = "(*.xlsx)|*.xlsx";
                sfd.Title = "结果输出:";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    this.TB_Put.Text = sfd.FileName;
                }
            }
        }

posted on 2020-07-02 17:05  林深鹿  阅读(274)  评论(0编辑  收藏  举报

导航