-5

everytime i change a file such as a .rft or .txt i want it to display the name in the title for e.g RFT Editor:docment.rft

here the code i am using atm

this.Text = "RFT Editor:" + saveFileDialog1.FileName;

hope someone can help

Glory Raj
  • 17,397
  • 27
  • 100
  • 203
Stefan
  • 1,233
  • 2
  • 8
  • 9

2 Answers2

1

Your question is poorly worded. You don't describe how the result you are getting is different from what you'd like it to be.

I can only guess the problem is that "RFT Editor:" + saveFileDialog1.FileName gives you a file name with an entire path, and to get "RFT Editor:docment.rft" as in your example you'd need "RFT Editor:" + System.IO.Path.GetFileName(saveFileDialog1.FileName) instead.

Konrad Morawski
  • 8,307
  • 7
  • 53
  • 91
0

Assuming you need this:

...
...

// Save clicked inside, not Cancel
if(saveFileDialog1.openDialog() == DialogResult.OK)
{
    // this.Text is same as only Text - in case of current class (matter of choice)
    Text = "RTF Editor: " + savefileDialog1.FileName;
    ...
    ...
}
Rolice
  • 3,063
  • 2
  • 24
  • 32