Search code examples
c#rft

c# change the form title by the savefile name.extension


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


Solution

  • 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;
        ...
        ...
    }