can someone tell me how to only show the name and not the full path in front of the name.
I found this code put in only show the extension or only the filename without the extension. What i want to be shown is the name of the file with the extension.
Like this:
example.txt.
Code:
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));
}
Thanks all for the help
var onlyfilename = Path.GetFileName(openFileDialog1.FileName);