的FileReference VS文件?文件、FileReference、VS

2023-09-08 15:05:39 作者:__葑茚丶誋憶

我想打一个Flash应用程序中,用户可以加载和往返于本地硬盘上保存文件。虽然我经常使用这样​​做的AIR应用程序的文件的FileStream 班,我还没有这样做之前,在SWF。

I want to make a Flash app in which the user can load and save files from and to their local hard drive. While I've often done this in AIR apps using the File and FileStream classes, I haven't done so before in an SWF.

这是我所知道的的FileReference 类是用于此,但它似乎已经因安全隐患的一些限制。我想知道的主要区别是使用的FileReference 类和使用的文件和的FileStream 类加载和保存文件。

From what I know the FileReference class is used for this, although it seems to have some restrictions due to security risks. I'd like to know what the main differences are between using the FileReference class and using the File and FileStream classes to load and save files.

推荐答案

文件类继承了的FileReference 的FileReference 是安全的flash播放器中使用(在浏览器中),因为它不会让你修改用户机器中的文件。

The File class extends the FileReference. FileReference is safe to be used in the FlashPlayer (in the browser) because it won't let you modify the files in the user machine.

如果你想打开一个文件,你需要为用户使用其打开:调用FileReference.browse() 要保存一个文件,你需要问用户保存它: FileReference.save()

If you want to open a file, you need to as for the user to open it for you with: FileReference.browse(). To save a file, you need to ask the user to save it: FileReference.save()

使用文件类,你可以打开,修改和保存文件,而这些对话。 此外,文件类为您提供了一堆有用的属性,如: File.desktopDirectory File.documentsDirectory 和这样的。照片 您可以在用户文件系统中操作文件时检查文件是否存在与存在财产,有多少的限制。

With File class you can open, modify and save files without those dialogs. Furthermore, the File class gives you a bunch of useful properties like: File.desktopDirectory, File.documentsDirectory and such. You can check if a file exists with the exists property and have a much restriction when manipulating file in the user file system.

您可以阅读更多关于的FileReference 和的文件类的文档。

You can read more about the FileReference and File classes in the docs.