我如何制作一个按钮,让您选择一个txt文件 [英] How do i make a button that lets you select a txt file
本文介绍了我如何制作一个按钮,让您选择一个txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试找出如何创建一个按钮来打开您的文件夹以选择计算机中的txt文件
Ive been trying to figure out how to make a button that opens your folder to select a txt file in your computer
和我试图找出如何在c#
and im trying to figure how to do that in c#
推荐答案
NumNufferZ,
Hi NumNufferZ,
谢谢您在这里发布.
对于您的问题,请尝试以下代码.
For your question, please try the following code.
string sSelectedFile;
string sSelectedFolder;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog choofdlog = new OpenFileDialog();
choofdlog.Filter = "All Files (*.*)|*.*";
choofdlog.FilterIndex = 1;
choofdlog.Multiselect = true;
if (choofdlog.ShowDialog() == DialogResult.OK)
sSelectedFile = choofdlog.FileName;
else
sSelectedFile = string.Empty;
}
我用gif显示.
我希望这会有所帮助.
最好的问候,
温迪
这篇关于我如何制作一个按钮,让您选择一个txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文