无声保存对话框
有没有办法默默地执行 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,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 useForceDirectories
ofFileMustExist
: if True, then useFileExists
ofNoReadOnlyReturn
: if True, then useFileIsReadOnly
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.