如何保存而不是另存为

发布于 2024-08-23 01:20:39 字数 104 浏览 1 评论 0原文

我正在创建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我家小可爱 2024-08-30 01:20:39

在某处创建一个字段,例如字符串文件名。最初将其设置为 null

打开文档时,将文件名存储在filename中。

当通过“另存为”保存文档时,还要将此文件名存储在filename中。

当调用 Save 时,检查 filename 的值。如果为 null,则调用“另存为”。如果不为null,则保存到filename中指定的文件名。

Create a field somewhere, say string filename. Set it to null 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 is null, invoke Save As instead. If it is not null, save to the file name specified in filename.

忘年祭陌 2024-08-30 01:20:39

通常的工作方式是跟踪用户打开或保存的文件名。

然后,当他们使用“保存”功能时,只需保存到先前指定的文件名即可。如果未指定文件,则显示另存为。

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.

弃爱 2024-08-30 01:20:39

“保存”不就是下面的内容(伪代码)吗?

Save() = 
    WriteTo(oldfilename)

SaveAs() = 
    stream = OpenDialog()
    oldfilename = stream.filename
    Save()

Isn't "Save" simply the following (in pseudocode)?

Save() = 
    WriteTo(oldfilename)

SaveAs() = 
    stream = OpenDialog()
    oldfilename = stream.filename
    Save()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文