flex examples of local directory operations

2010-11-16  来源:本站原创  分类:Flash  人气:145 

<? Xml version = "1.0" encoding = "utf-8"?>
<S: WindowedApplication xmlns: fx = "http://ns.adobe.com/mxml/2009"
xmlns: s = "library: / / ns.adobe.com / flex / spark"
xmlns: mx = "library: / / ns.adobe.com / flex / halo">

<fx:Script>
<! [CDATA [
import flash.filesystem.File;

private function myURL01 (): void {
/ * File object can represent either a specific directory, you can also represent a specified file. * /
/ / 1, specify an absolute path
var dirFile: File = new File ("D: / music / man");
trace ("0," + dirFile.nativePath);
/ / 2, to obtain system user file directory and the current project directory
trace ("1," + File.userDirectory.nativePath); / / C: \ Documents and Settings \ a
trace ("2," + File.documentsDirectory.nativePath); / / 2, C: \ Documents and Settings \ a \ My Documents
trace ("3," + File.desktopDirectory.nativePath); / / 3, C: \ Documents and Settings \ a \ Desktop
/ / Compatible (that is common to) all kinds of operating systems stored in this way the path way called flex
trace ("4," + File.applicationStorageDirectory.resolvePath ("mapMarker /"). url); / / app-storage: / mapMarker
trace ("5," + File.applicationStorageDirectory.nativePath); / / 4, C: \ Documents and Settings \ a \ Application Data \ fileUrl \ Local Store
trace ("6," + thisProURL (File.applicationDirectory.nativePath)); / / (custom) 5, C: \ Documents and Settings \ a \ Adobe Flash Builder Beta 2 \ fileUrl
trace ("7," + File.applicationDirectory.nativePath); / / 6, C: \ Documents and Settings \ a \ Adobe Flash Builder Beta 2 \ fileUrl \ bin-debug
/ / 3, additional and extended the specified directory
trace ("8," + File.userDirectory.resolvePath ("My Music"). nativePath); / / 7, C: \ Documents and Settings \ a \ My Music
trace ("----------------------------------------------- ----------------------");
}

private function thisProURL (strURL: String): String {
var str: String = "";
var len: int = strURL.split ("\ \"). length;
for (var i: int = 0; i <len - 1; i + +) {
if (i! = len - 2) {
str + = strURL.split ("\ \") [i] + "\ \";
} Else {
str = str + strURL.split ("\ \") [len - 2];
}
}
return str;
}

/ / 4, a specified directory traversal
public function bianliFile (dirFile: File): void {
if (dirFile.exists) {/ / specified file object exists
if (dirFile.isDirectory) {/ / specify whether the object is a directory file
var sonFileArray: Array = dirFile.getDirectoryListing ();
var sonsLength: uint = sonFileArray.length;
for (var i: int = 0; i <sonsLength; i + +) {
if (sonFileArray [i]. isDirectory) {/ / if a directory
trace ("is a directory ---" + sonFileArray [i]. nativePath);
} Else {/ / is the file
trace ("is a file ---" + sonFileArray [i]. nativePath);
}
}
trace ("----------------------------------------------- ----------------------");
} Else {
trace ("the specified object is not a directory");
}
} Else {
trace ("the specified object directory does not exist");
}
}

/ / 5, to obtain more information on the specified directory
public function infoDirFile (dirFile: File): void {
if (dirFile.exists) {/ / specified file object exists
if (dirFile.isDirectory) {/ / specify whether the object is a directory file
trace ("Directory creation time:" + dirFile.creationDate.fullYear + "years"
+ (DirFile.creationDate.month + 1) + "on" + dirFile.creationDate.date + "Day"
+ DirFile.creationDate.hours + "time" + dirFile.creationDate.minutes + "sub" + dirFile.creationDate.seconds + "seconds");
trace ("directory created by:" + dirFile.creator);
trace ("List of extensions:" + dirFile.extension);
trace ("directory is hidden:" + dirFile.isHidden);
trace ("directory name:" + dirFile.name);
trace ("absolute path:" + dirFile.nativePath);
trace ("Directory size:" + dirFile.size);
trace ("----------------------------------------------- ----------------------");
} Else {
trace ("the specified object is not a directory");
}
} Else {
trace ("the specified object directory does not exist");
}
}

/ / 6, in the specified directory to create a directory, the directory already exists if not created, the code is not executed
public function createDirFile (dirFile: File, newDirName: String): void {
var sonDirFile: File = dirFile.resolvePath (newDirName);
sonDirFile.createDirectory ();
}

/ / 7, in the specified directory to delete a directory
public function deleteDirFile (dirFile: File, delDirName: String): void {
var sonDirFile: File = dirFile.resolvePath (delDirName);
sonDirFile.moveToTrash (); / / move to the Recycle Bin
/ / SonDirFile.deleteFile (); / / completely delete the file, the current problems
}

/ / 8, to the specified directory from a specified directory to another specified directory shear
public function moveDirFile (fromDirFile: File, toDirFile: File, moveDirName: String): void {
/ / Var moveDirFile: File = fromDirFile.resolvePath (moveDirName);
/ / MoveDirFile.moveTo (toDirFile, false);
}

/ / 9, to the specified directory from a specified directory to another specified directory
public function copyDirFile (fromDirFile: File, toDirFile: File, copyDirName: String): void {
try {
var copyDirFile: File = fromDirFile.resolvePath (copyDirName);
copyDirFile.copyTo (toDirFile, true);
} Catch (error: Error) {
trace (error.message);
}
}

]]>
</ Fx: Script>

<mx:Button x="100" y="20" label=" Gets the system directory " click="myURL01();"/>
<mx:Button x="100" y="60" label=" Through a specified directory " click="bianliFile(File.userDirectory);"/>
<mx:Button x="100" y="100" label=" Access to a specified directory details " click="infoDirFile(File.userDirectory);"/>
<mx:Button x="100" y="140" label=" In the specified directory, create a directory " click="createDirFile(File.userDirectory,' Mr. Chong ');"/>
<mx:Button x="100" y="180" label=" In the specified directory to delete a directory " click="deleteDirFile(File.userDirectory,' On on on ');"/>
<Mx: Button x = "100" y = "220" label = "to specify a directory from one cut to another specified directory specified directory"
click = "moveDirFile (File.userDirectory, File.documentsDirectory, 'sss');"/>
<Mx: Button x = "100" y = "260" label = "to specify a directory from a specified directory to another specified directory"
click = "copyDirFile (File.userDirectory, File.documentsDirectory, 'sss');"/>

<fx:Declarations>
<! - Place non-visual elements (eg, services, value objects) here ->
</ Fx: Declarations>

</ S: WindowedApplication>

相关文章
  • flex examples of local directory operations 2010-11-16

    <? Xml version = "1.0" encoding = "utf-8"?> <S: WindowedApplication xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: s = "library: / / ns.adobe.com / flex / spark" xmlns: mx = "library: / / ns.adobe.

  • flex (air) instance of the local directory operations (transfer) 2010-09-22

    flex (air) operation on an instance of a local directory articles Category: Flash Programming Mxml code <? Xml version = "1.0" encoding = "utf-8"?> <S: WindowedApplication xmlns: fx = "http://ns.adobe.com/mxml/2009"

  • flex (air) operation example of the local directory (change) 2010-09-22

    flex (air) operation example of the local directory articles Category: Flash Programming Mxml code <? Xml version = "1.0" encoding = "utf-8"?> <S: WindowedApplication xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns

  • Flex3 Component Explorer Flex examples of various components 2010-11-14

    Flex3 Component Explorer Flex examples of various components http://examples.adobe.com/flex3/componentexplorer/explorer.html

  • Getting Started flex examples 2010-11-18

    Getting Started flex examples

  • sqoop could not find any valid local directory exception resolution 2011-09-07

    Did not change any configuration in the case of sqoop sudden alarm: org.apache.hadoop.util.diskchecker $ diskerrorexception: could not find any valid local directory; The original hard disk space is full, taking up to 100%; delete useless data, sqoop

  • flex (air) operation example of the local directory 2010-06-19

    <?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> &

  • flex examples of shared object access to local data (intermediate) 2010-06-19

    1, shareObj.mxml <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo&qu

  • flex examples of shared object access to local data (primary) 2010-06-19

    1, shareObj.mxml <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo&qu

  • flex examples of international 2010-03-11

    Author: wasw100 Website: http://www.wasw100.com/flex/flex_internationalization_example.html Test environment: MyElipse (with Flex Builder3 plug-ins) Can http://www.javaeye.com/wiki/flex/1804-flex-internationalization set, here are more complementary,

  • Directory operations 2010-07-27

    [Size = x-small;] directory is stored on disk data structure, which consists of a number of directory entry form. Each directory entry describes a point to other directory or file entry. Directory function is to organize files into hierarchies, easy

  • Python file operations and directory operations 2010-03-15

    We know that the file name, directory name and link name is a string used as an identifier, but give us an identifier, how do we make sure it is a regular file referred to in the end file name, directory name or the link name it ? At this time, we ca

  • flex examples of program execution sequence 2010-06-19

    Core Description: 1, view of a flex system program execution sequence: 1. Global variable region; 2. External custom component area; 3. Four keywords (preinitialize / initialize / creationComplete / applicationComplete). 2, defines a class of referen

  • php read file and then download. file directory operations. create a directory function. Browse Catalog 2010-07-16

    Download speed limit <? Php $ File = "test.mp3"; / / file to be send to the client $ Speed = 8.5; / / 8,5 kb / s download rate limit if (file_exists ($ file) & & is_file ($ file)) ( header ("Cache-control: private"); header

  • Flex examples of image filter effects 2010-07-26

    Have enclosed a few other examples cited: http://www.cnblogs.com/xxcainiao/archive/2008/11/08/1329664.html 1: Spotlight Effect: Examples: http://www.rphelan.com/flex/SpotlightDemo/SpotlightDemo.html Source: http://www.rphelan.com/flex/SpotlightDemo/s

  • jdk6.0 from entry to master ----- chapter4 - directory operations 2010-09-09

    1, test hard disk space package space; import java.io.File; public class TestSpace { public static void main(String[] args) throws SecurityException { File f=new File(args[0]); System.out.println("TotalSpace: "+f.getTotalSpace()); // Bytes Syste

  • action on the use of the package AIR local database operations sqlite 2010-11-01

    In addition to using air development language can be used to store the xml and the background to provide data, can also have their own small local database, sqlite, database format for the db or db3. The benefits of using the local database is lightw

  • Python file and directory operations 2010-12-28

    This article will explain in detail the use of these functions. First, we introduce the Python language similar to the Windows system dir command lists the file functions, and then describe how to test a file name corresponds to a standard file, dire

  • Summary linux file directory operations (transfer) 2011-04-19

    Files and directories related to the Linux operating system is an important part of the management of operations, this article will summarize the linux directory-related operations. Change directory command: cd directory name cd is change directory c

  • Flex examples of source image erasure effect 2010-06-17

    <?xml version="1.0" encoding="utf-8"?> <!-- alwaysInFront="true" Remains in the other components that form before useHandCursor="true" Mouse over the component is displayed as hand-type mouse --> <s:W