-5

每次我更改诸如 .rft 或 .txt 之类的文件时,我希望它在标题中显示名称,例如RFT Editor:docment.rft

这里是我使用 atm 的代码

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

希望有人能帮忙

4

2 回答 2

1

你的问题措辞不好。你没有描述你得到的结果与你想要的结果有何不同。

我只能猜到问题在于它"RFT Editor:" + saveFileDialog1.FileName为您提供了一个包含完整路径的文件名,并在您的示例中获取“RFT Editor:docment.rft” ,而不是您需要的 "RFT Editor:" + System.IO.Path.GetFileName(saveFileDialog1.FileName)

于 2011-12-06T16:18:57.227 回答
0

假设你需要这个:

...
...

// 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;
    ...
    ...
}
于 2011-12-06T16:18:11.067 回答