使用 Adob​​e AIR 执行自动保存,无需打开弹出保存框

发布于 2025-01-08 08:17:12 字数 317 浏览 2 评论 0原文

我有一个 AIR 应用程序,我想实现自动保存功能。目前,我有一项服务使用计时器来检查应用程序中当前活动文件的状态,然后如果该文件更改为新文件,该服务会检查当前文件名(如果已更改),则该文件已更改。 发生这种情况时,我想执行自动保存,我可以这样做,但问题是调用保存时会打开保存弹出保存框,这就是我调用保存函数的方式:

var file:File = File.userDirectory .resolvePath( 文件路径 ); 文件.save( jsonToExport );

有没有办法在不打开弹出框的情况下调用 save() 函数?

谢谢

斯蒂芬

I've an AIR app that I'd like to implement a auto-save functionality. Currently I have a service that uses a timer to check the status of the current active file in my app, then if the file changes to a new file, the service checks the current file name if that has changed then the file has changed.
When this happens I want to perform a auto-save, which I can do but the problem is that the save popup save box opens when the save is called, this is how I call the save function:

var file:File = File.userDirectory.resolvePath( filepath );
file.save( jsonToExport );

Is there a way to call the save() function without a popup box opening?

Thanks

Stephen

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

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

发布评论

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

评论(1

梦情居士 2025-01-15 08:17:12

尝试使用 FileStream 直接写入文件,而不是使用 File 的 save 方法:

var file:File = File.userDirectory.resolvePath( filepath );

//Instantiate new file stream
var fs:FileStream = new FileStream();

//add optional event listener to do some action once finished
fs.addEventListener(Event.CLOSE, fileWrittenComplete);

//open the file in write mode       
fs.openAsync(file, FileMode.WRITE);

//write your data to file   
fs.writeUTFBytes(jsonToExport);    

//close the file stream
fs.close();

Rather than using the File's save method, try using a FileStream to write the file directly:

var file:File = File.userDirectory.resolvePath( filepath );

//Instantiate new file stream
var fs:FileStream = new FileStream();

//add optional event listener to do some action once finished
fs.addEventListener(Event.CLOSE, fileWrittenComplete);

//open the file in write mode       
fs.openAsync(file, FileMode.WRITE);

//write your data to file   
fs.writeUTFBytes(jsonToExport);    

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