无声保存对话框

发布于 2024-11-28 13:53:10 字数 92 浏览 0 评论 0原文

有没有办法默默地执行 saveDialog ,意思是不要求用户指定文件名?

它旨在用于现有代码自动化。假设我们不能使用不同的 saveDialog 对象。

Is there a way to execute saveDialog, silently , meaning, not asking the user to specify file name?

Its intended for existing code automation. lets assume we cannot use different saveDialog Object.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

黯淡〆 2024-12-05 13:53:10

好吧,SaveDialog 的唯一目的是提供文件名,因此显而易见的简短回答是:不要使用 SaveDialog。

但是,如果您想考虑 SaveDialog 的所有选项,那么您必须在保存文件之前自行进行一些检查。适用的非可视选项以及处理这些选项所涉及的关键例程是:

  • ofPathMustExist:如果为 False,则使用 ForceDirectories
  • ofFileMustExist:如果为 True,则使用 FileExists
  • ofNoReadOnlyReturn:如果为 True ,然后使用 FileIsReadOnly
  • ofNoDereferenceLinks:将其反转用作 FileExists 中的 FollowLink 参数。

所有其他适用的选项(ofOverwritePrompt = True、ofPathMustExist = True、ofNoTestFileCreate = False)均通过在保存周围使用 try - except 块进行匹配文件的。

Well, the only purpose the SaveDialog has is providing a file name, so the obvious short anser is: do not use the SaveDialog.

But if you want to take all the options of the SaveDialog into account, then you have to do some checking yourself before saving the file. The non-visual options that apply, and the key routines that are involved for handling those options are:

  • ofPathMustExist: if False, then use ForceDirectories
  • ofFileMustExist: if True, then use FileExists
  • ofNoReadOnlyReturn: if True, then use FileIsReadOnly
  • ofNoDereferenceLinks: use it, inverted, as the FollowLink parameter in FileExists.

All other applicable options (ofOverwritePrompt = True, ofPathMustExist = True, ofNoTestFileCreate = False) are matched by using a try - except block around the saving of the file.

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