gpt4 book ai didi

c# - 打开文件对话框只有名称

转载 作者:行者123 更新时间:2023-11-30 13:13:11 25 4
gpt4 key购买 nike

<分区>

谁能告诉我如何只显示名称而不显示名称前面的完整路径。我发现这段代码只显示扩展名或只显示没有扩展名的文件名。我想要显示的是带有扩展名的文件名。
像这样:例子.txt.

代码:

private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Binary Files (.BIN; .md6; .md7)|*.BIN; *.md6; *.md7|All Files (*.*)|*.*";


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.StreamReader sr = new
System.IO.StreamReader(openFileDialog1.FileName);
sr.Close();
}
}
String filedata = openFileDialog1.FileName;

openFileDialog1.Title = ("Choose a file");
openFileDialog1.InitialDirectory = "C:\\Projects\\flashloader2013\\mainapplication\\Bootfiles";

//textBox1.Text = (System.IO.Path.GetExtension(openFileDialog1.FileName));
textBox1.Text = (System.IO.Path.Get(openFileDialog1.FileName));
}

感谢大家的帮助

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com