File applicationdirectory air




















Hide Inherited Public Properties. Show Inherited Public Properties. A reference to the class object or constructor function for a given object instance. Hide Inherited Public Methods.

Show Inherited Public Methods. Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. Displays a file-browsing dialog box that lets the user select a file to upload.

Opens a dialog box that lets the user download a file from a remote server. Checks whether the EventDispatcher object has any listeners registered for a specific type of event. Indicates whether an object has a specified property defined.

Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. Indicates whether the specified property exists and is enumerable.

Opens a dialog box that lets the user save a file to the local filesystem. Sets the availability of a dynamic property for loop operations.

Returns the string representation of this object, formatted according to locale-specific conventions. Starts the upload of a file selected by a user to a remote server. Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. Click for more information on events.

Hide Inherited Events. Show Inherited Events. Implementation public static function get applicationDirectory : File See also applicationStorageDirectory. Implementation public static function get applicationStorageDirectory : File Example How to use this example The following code creates a File object pointing to the "images" subdirectory of the application storage directory.

Implementation public static function get desktopDirectory : File Example How to use this example The following code outputs a list of files and directories contained in the user's desktop directory. Implementation public static function get documentsDirectory : File Example How to use this example The following code uses the File. Implementation public function get exists : Boolean Example How to use this example The following code creates a temporary file, then deletes it and uses the File.

Implementation public function get icon : Icon Example How to use this example The following code shows how to find the image in the icon array that has the greatest height, and it sets a Bitmap object to that image. File; import flash. Implementation public function get isDirectory : Boolean Example How to use this example The following code creates an array of File objects pointing to files and directories in the user directory and then uses the isDirectory property to list only those File objects that point to directories not to files.

Implementation public function get isHidden : Boolean Example How to use this example The following code creates an array of File objects pointing to files and directories in the user directory and then uses the isHidden property to list hidden files and directories.

On Mac OS, directories can be designated as packages and will show up in the Finder as a single file rather than as a directory.

This property is set to true if the referenced directory is a package, and false if the file is not a directory, does not exist, or is not a package. On other operating systems, this property is always set to false. Implementation public function get isPackage : Boolean. Implementation public function get isSymbolicLink : Boolean. Implementation public static function get lineEnding : String Example How to use this example The following code writes a string str to a text file and uses the File.

It is far better to use the following static properties, which represent commonly used directories, and which are valid on all platforms: File. Implementation public function get nativePath : String public function set nativePath value: String : void Throws SecurityError — The caller is not in the application security sandbox.

ArgumentError — The syntax of the path is invalid. Example How to use this example The following code shows the difference between the nativePath property and the url property of a File object. The comments show results on an example Windows computer. Implementation public function get parent : File Example How to use this example The following code uses the parent property to show the directory that contains a temporary file.

Implementation public static function get separator : String Example How to use this example The following code uses the getRelativePath method to get the relative path between a directory and a file. The code then uses the File. Implementation public function get spaceAvailable : Number.

The following code opens a file a test. SecurityError — The caller is not in the application security sandbox. The following code shows the difference between the nativePath property and the url property of a File object.

Implementation public static function get userDirectory : File Example How to use this example The following code outputs a list of files and directories contained in the root level of the user directory: import flash. Events cancel : Event — Dispatched when the user clicks the Cancel button in the Open File dialog box.

See also browseForOpen browseForSave select flash. The following code uses the File. When the directory is selected, the code lists the contents of the selected directory in the trace output. When the file is selected, the code reads the file data into a string. Event; import flash. When the files are selected, the code outputs the paths for the selected files.

Events cancel : Event — Dispatched when the user clicks the Cancel button in the Save File dialog box. See also browseDirectory browseForOpen select flash. When the files are selected, the code saves data to the selected file path. WRITE ; stream. In addition, canonicalization converts short filesnames to long filenames on Windows. Example How to use this example The following code shows how to use the canonicalize method to find the correct capitalization of a directory name.

Before running this example, create a directory named AIR Test on the desktop of your computer. The following code shows how to use the canonicalize method to find the long name of a Windows directory based on its short name. Returns File. Throws IOError — The source does not exist; or the destination exists and overwrite is false ; or the source could not be copied to the target; or the source and destination refer to the same file or folder and overwrite is set to true.

On Windows, you cannot copy a file that is open or a directory that contains a file that is open. See also copyToAsync moveTo. The following code shows how to use the copyTo method to copy a file. Before running this code, create a test1. The resulting copied file is named test2. When you set the clobber parameter to true , the operation overwrites any existing test2.

The try and catch statements show how to respond to errors. Events complete : Event — Dispatched when the file or directory has been successfully copied. See also copyTo moveToAsync. The following code shows how to use the copyToAsync method to copy a file.

Before running this code, be sure to create a test1. Throws IOError — The directory did not exist and could not be created. Example How to use this example The following code moves a file named test. The call to the createDirectory method ensures that the AIR Test directory exists before the file is moved. Returns File — A File object referencing the new temporary directory.

See also createTempFile. The following code uses the createTempFile method to obtain a reference to a new temporary directory. Returns File — A File object referencing the new temporary file. See also createTempDirectory. You can also pass this path to the File constructor function, as in the following:. You can use the getDirectoryListing method of a File object to get an array of File objects pointing to files and subdirectories at the root level of a directory.

For more information, see Enumerating directories. The File class includes the following methods that present a system dialog box in which the user can select a file to assign to the object:.

These methods are each asynchronous. The browseForOpen and browseForSave methods dispatch the select event when the user selects a file or a target path, in the case of browseForSave. With the browseForOpen and browseForSave methods, upon selection the target File object points to the selected files.

The browseForOpenMultiple method dispatches a selectMultiple event when the user selects files. The selectMultiple event is of type FileListEvent, which has a files property that is an array of File objects pointing to the selected files. If the application has another browser dialog box open when you call a browse method, the runtime throws an Error exception. You can also modify the path of an existing File object by calling the resolvePath method or by modifying the nativePath or url property of the object, as in the following examples on Windows :.

Use to specify a path relative to the root directory of the installed application the directory that contains the application.

For example, the following path points to an images subdirectory of the directory of the installed application:. Use to specify a path relative to the application store directory.

For each installed application, AIR defines a unique application store directory, which is a useful place to store data specific to that application. For example, the following path points to a prefs.

You can use the getRelativePath method to find the relative path between two files:. The second parameter of the getRelativePath method, the useDotDot parameter, allows for.. File and path names are not case sensitive on Windows and Mac OS. In the following, two File objects point to the same file:. However, documents and directory names do include capitalization. For example, the following assumes that there is a folder named AIR Test in the documents directory, as in the following examples:.

The canonicalize method converts the nativePath object to use the correct capitalization for the file or directory name. On case sensitive file systems such as Linux , when multiple files exists with names differing only in case, the canonicalize method adjusts the path to match the first file found in an order determined by the file system.

You can also use the canonicalize method to convert short file names "8. Symbolic links allow a file to point to another file or directory on disk. Although similar, symbolic links are not the same as aliases. An alias is always reported as a file rather than a directory , and reading or writing to an alias or shortcut never affects the original file or directory that it points to.

On the other hand, a symbolic link behaves exactly like the file or directory it points to. It can be reported as a file or a directory, and reading or writing to a symbolic link affects the file or directory that it points to, not the symbolic link itself. The File class includes the isPackage and isSymbolicLink properties for checking if a File object references a package or symbolic link.

The canonicalize method changes the path of a symbolic link to point to the file or directory to which the link refers. The spaceAvailable property of a File object is the space available for use at the File location, in bytes. For example, the following code checks the space available in the application storage directory:. If the File object references a directory, the spaceAvailable property indicates the space in the directory that files can use.

If the File object references a file, the spaceAvailable property indicates the space into which the file could grow. If the file location does not exist, the spaceAvailable property is set to 0. If the File object references a symbolic link, the spaceAvailable property is set to space available at the location the symbolic link points to. Typically the space available for a directory or file is the same as the space available on the volume containing the directory or file.

However, space available can take into account quotas and per-directory limits. Adding a file or directory to a volume generally requires more space than the actual size of the file or the size of the contents of the directory. For example, the operating system may require more space to store index information. Or the disk sectors required may use additional space. Also, available space changes dynamically. However, documents and directory names do include capitalization. For example, the following assumes that there is a folder named AIR Test in the documents directory, as in the following examples:.

The canonicalize method converts the nativePath object to use the correct capitalization for the file or directory name. On case sensitive file systems such as Linux , when multiple files exists with names differing only in case, the canonicalize method adjusts the path to match the first file found in an order determined by the file system. You can also use the canonicalize method to convert short file names "8. Symbolic links allow a file to point to another file or directory on disk.

Although similar, symbolic links are not the same as aliases. An alias is always reported as a file rather than a directory , and reading or writing to an alias or shortcut never affects the original file or directory that it points to. On the other hand, a symbolic link behaves exactly like the file or directory it points to. It can be reported as a file or a directory, and reading or writing to a symbolic link affects the file or directory that it points to, not the symbolic link itself.

The File class includes the isPackage and isSymbolicLink properties for checking if a File object references a package or symbolic link. The canonicalize method changes the path of a symbolic link to point to the file or directory to which the link refers. The spaceAvailable property of a File object is the space available for use at the File location, in bytes. For example, the following code checks the space available in the application storage directory:.

If the File object references a directory, the spaceAvailable property indicates the space in the directory that files can use. If the File object references a file, the spaceAvailable property indicates the space into which the file could grow. If the file location does not exist, the spaceAvailable property is set to 0. If the File object references a symbolic link, the spaceAvailable property is set to space available at the location the symbolic link points to.

Typically the space available for a directory or file is the same as the space available on the volume containing the directory or file. However, space available can take into account quotas and per-directory limits. Adding a file or directory to a volume generally requires more space than the actual size of the file or the size of the contents of the directory.

For example, the operating system may require more space to store index information. Or the disk sectors required may use additional space. Also, available space changes dynamically. So, you cannot expect to allocate all of the reported space for file storage. For information on writing to the file system, see Reading and writing files.

In AIR 2, you can open a file using the application registered by the operating system to open it. Use the openWithDefaultApplication method of a File object to open the file. For example, the following code opens a file named test. The following code lets the user navigate to an mp3 file and open it in the default application for playing mp3 files:.

You cannot use the openWithDefaultApplication method with files located in the application directory. Attempting to open one of these files using the openWithDefaultApplication method results in an exception. For a complete list of prevented filetypes, see the language reference entry for the File.

Adobe Flash Platform. A File object is a pointer to a file or directory in the file system. About the File class You can use the File class for the following: Getting the path to special directories, including the user directory, the user's documents directory, the directory from which the application was launched, and the application directory Coping files and directories Moving files and directories Deleting files and directories or moving them to the trash Listing files and directories contained in a directory Creating temporary files and folders Once a File object points to a file path, you can use it to read and write file data, using the FileStream class.

Paths of File objects Each File object has two properties that each define its path: Property Description nativePath Specifies the platform-specific path to a file.

Note: When a platform does not define standard locations for desktop, documents, or user directories, File. Pointing a File object to a directory There are different ways to set a File object to point to a directory.

Pointing to the desktop directory You can point a File object to the desktop. Pointing to the application storage directory You can point a File object to the application storage directory. Pointing to the application directory You can point a File object to the directory in which the application was installed, known as the application directory. The nativePath property is an empty string.

Always use the URL to access files in the application directory rather than a native path. Pointing to the file system root The File. Note: The root of the file system is not readable on Android. For example, spaceAvailable is always 0. Navigating to relative paths You can use the resolvePath method to obtain a path relative to another given path. Letting the user browse to select a directory The File class includes the browseForDirectory method, which presents a system dialog box in which the user can select a directory to assign to the object.

Calling this method has no effect; a cancel event is dispatched immediately. Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search.

I am trying to load folder names into an array for later use. It works fine on my desktop but when I test it on a mobile device both Android and iPhone and it is calling another function - displayFlags ; - before I get the folder names into an array. Below is the code that loads file and the array. Is there a way to check when the array is available and call a function after its loaded?

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.



0コメント

  • 1000 / 1000