flash 将 ByteArray 写入磁盘上的文件

发布于 2024-08-11 05:38:11 字数 390 浏览 5 评论 0原文

我需要使用 Flash AS3 将 ByteArray 写入本地磁盘上的文件。 flash 应用程序在本地运行(它是一个投影仪 exe)。

我发现 FileReference 类带有 save() 函数,效果非常好。唯一的问题是,该函数打开一个文件浏览器,让用户选择存储文件的位置。但是 - 我已经将路径作为字符串保存到此位置而无需用户操作(因为我一次性将大量文件导出到此目录中并且不希望用户手动选择每个文件)。

有没有一种方法可以在不打开文件浏览器的情况下将字节数组从投影仪存储到本地磁盘?

我还使用 mdm Zinc,它实际上提供了一个将 ByteArray 保存到磁盘的函数,但该函数由于某些未知原因不起作用。我已经提交了错误报告,但我需要非常紧急地让它发挥作用,所以我正在寻找替代方案!

谢谢!

I need to write a ByteArray to a file on local disk with Flash AS3. The flashapplication is run locally (it's a projector exe).

I found the FileReference class with the save() function which works perfect. The only problem is, that this function opens a filebrowser and let's the user select where to store the file. However - i have the path already as string and need to save to this location without useraction (since i'm exporting a lot of files into this directory in one go and don't want the user to choose each one manually).

Is there a way to store a bytearray from a projector to local disk without opening a filebrowser?

I'm also using mdm Zinc, which actually provides a function to save a ByteArray to disk, but this function is for some unknown reasons not working. I already filed a bugreport, but I need to get this to work very urgently, so i'm looking for alternatives!

Thanks!

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

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

发布评论

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

评论(2

新人笑 2024-08-18 05:38:11

请注意,您正在将应用程序作为 .exe 运行,我假设您正在使用 AIR 的某种变体,并且具有访问文件系统的安全权限。您应该查看 FileStream 类。这是一个非常简单的示例,说明我如何使用它将 ByteArray 写入硬编码文件位置。

var fs : FileStream = new FileStream();
var targetFile : File = File.desktopDirectory.resolvePath("test.raw");
fs.open(targetFile, FileMode.WRITE);
fs.writeBytes(myByteArray,0,myByteArray.length);
fs.close();

Noting that you are running your application as an .exe I assume you are using some variant of AIR, and have a security permission to access the filesystem. You should take a look at the FileStream class. Here is a very simple example of how I used it to write a ByteArray to a hard-coded file location.

var fs : FileStream = new FileStream();
var targetFile : File = File.desktopDirectory.resolvePath("test.raw");
fs.open(targetFile, FileMode.WRITE);
fs.writeBytes(myByteArray,0,myByteArray.length);
fs.close();
恋竹姑娘 2024-08-18 05:38:11

如果你需要的只是持久性(读你写的东西),你可以看看 SharedObject。

If all you need is persistence (you read what you write), you can take a look at SharedObject.

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