如何保存而不是另存为
我正在创建一个 Richtextbox 编辑器,需要添加保存功能以及另存为。我可以使用 savefiledialog 轻松执行另存为功能,但我不确定如何在没有此功能的情况下保存。有人可以帮忙吗?
I'm creating a richtextbox editor and need to put a save function as well as a save as. I can easily do a save as function by using the savefiledialog but im not sure how to save without this. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在某处创建一个字段,例如
字符串文件名
。最初将其设置为null
。打开文档时,将文件名存储在
filename
中。当通过“另存为”保存文档时,还要将此文件名存储在
filename
中。当调用 Save 时,检查
filename
的值。如果为null
,则调用“另存为”。如果不为null
,则保存到filename
中指定的文件名。Create a field somewhere, say
string filename
. Set it tonull
initially.When a document is opened, store the file name in a
filename
.When a document is saved through Save As, also store this file name in
filename
.When Save is invoked, check the value of
filename
. If it isnull
, invoke Save As instead. If it is notnull
, save to the file name specified infilename
.通常的工作方式是跟踪用户打开或保存的文件名。
然后,当他们使用“保存”功能时,只需保存到先前指定的文件名即可。如果未指定文件,则显示另存为。
The way this usually works is to keep track of the file name the user either opened or saved as.
Then, when they use the Save function, simply save to the file name that was previously specified. If no file has been specified, then show the Save As.
“保存”不就是下面的内容(伪代码)吗?
Isn't "Save" simply the following (in pseudocode)?