適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隱藏篩選
flash.filesystem 

File  - AS3

套件x

最上層
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

語言元素

全域常數
全域函數
運算子
陳述式、關鍵字和指令
特殊類型

附錄

新增內容
編譯器錯誤
編譯器警告
執行階段錯誤
移轉至 ActionScript 3
支援的字元集
僅限 MXML 標籤
移動 XML 元素
Timed Text 標籤
不建議元素清單
AccessibilityImplementation 常數
如何使用 ActionScript 範例
法律聲明
套件flash.filesystem
類別public class File
繼承File Inheritance FileReference Inheritance EventDispatcher Inheritance Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

File 物件代表檔案或目錄的路徑。這可能是現有檔案或目錄,或是尚未存在的檔案或目錄,例如,它可能代表您想要建立之檔案或目錄的路徑。

File 類別有多個可取得檔案系統相關資訊及執行作業 (如複製檔案和目錄) 的屬性和方法。

您可以一併使用 File 物件與 FileStream 類別來讀取及寫入檔案。

File 類別會擴充 FileReference 類別。在 Flash® Player 及 Adobe® AIR® 中提供的 FileReference 類別,代表指向檔案的指標,但 File 類別會加入 Flash Player (在瀏覽器中執行的 SWF) 基於安全考量而未公開的屬性和方法。

File 類別包括可讓您參考常用目錄位置的靜態屬性。這些靜態屬性包括:

  • File.applicationStorageDirectory — 每個已安裝 AIR 應用程式唯一的儲存目錄
  • File.applicationDirectory — 應用程式 (和所有已安裝的資源) 安裝位置的唯讀目錄
  • File.desktopDirectory — 使用者的桌面目錄
  • File.documentsDirectory — 使用者的文件目錄
  • File.userDirectory — 使用者目錄

這些屬性在不同作業系統上都包含有意義的值。例如,Mac OS、Linux 和 Windows 都各自有不同的使用者桌面目錄原生路徑。然而,File.desktopDirectory 屬性會指向這些平台上正確的桌面目錄路徑。若要撰寫可跨平台運作的應用程式,請將這些屬性做為參考其他應用程式所使用之檔案的基礎。然後使用 resolvePath() 方法來修改路徑。例如,此程式碼會指向應用程式儲存目錄中的 preferences.xml 檔案:

 var prefsFile:File = File.applicationStorageDirectory;
  prefsFile = prefsFile.resolvePath("preferences.xml");

如果您在參考檔案時使用常值原生路徑,則該路徑只能在單一平台上運作。例如,下列 File 物件僅能在 Windows 上運作:

new File("C:\Documents and Settings\joe\My Documents\test.txt")

應用程式儲存目錄十分有用,能夠使 AIR 應用程式擁有應用程式專屬的儲存目錄。這是由 File.applicationStorageDirectory 屬性所定義。請注意,在 Mac OS 上,這個位置已在 AIR 3.2 與 AIR 3.3 之間變更。

請勿從應用程式目錄 (AIR 應用程式安裝之處) 中新增或移除內容。這麼做可能會破壞 AIR 應用程式並使應用程式簽章無效。根據預設,AIR 不允許您寫入應用程式目錄,因為並非所有作業系統上所有的使用者帳戶都能寫入目錄。使用應用程式儲存目錄來寫入內部應用程式檔案。使用文件目錄來寫入使用者預期在應用程式外部所使用的檔案,例如編輯好的圖片或文字檔案。

相關 API 元素



公用屬性
 屬性定義自
      applicationDirectory : File
[靜態] [唯讀] 包含應用程式已安裝檔案的檔案夾。
File
      applicationStorageDirectory : File
[靜態] [唯讀] 應用程式的私用儲存目錄。
File
      cacheDirectory : File
[靜態] [唯讀] 應用程式的快取目錄。
File
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
 InheritedcreationDate : Date
[唯讀] 本機磁碟上的檔案建立日期。
FileReference
 Inheritedcreator : String
[唯讀] 檔案的 Macintosh 建立者類型,只能在 Mac OS X 之前的 Mac OS 版本中使用。
FileReference
 Inheriteddata : ByteArray
[唯讀] ByteArray 物件,代表成功呼叫 load() 方法後載入的檔案所包含的資料。
FileReference
      desktopDirectory : File
[靜態] [唯讀] 使用者的桌面目錄。
File
      documentsDirectory : File
[靜態] [唯讀] 使用者的文件目錄。
File
      downloaded : Boolean
指出參考檔案或目錄是否已經下載 (從網際網路)。
File
      exists : Boolean
[唯讀] 指出參考的檔案或目錄是否存在。
File
 Inherited    extension : String
[唯讀] 副檔名。
FileReference
      icon : Icon
[唯讀] 包含為檔案所定義之圖示的 Icon 物件。
File
      isDirectory : Boolean
[唯讀] 指出是否參考目錄。
File
      isHidden : Boolean
[唯讀] 指出參考的檔案或目錄是否「隱藏」。如果參考的檔案或目錄是隱藏的,則此值為 true,否則為 false。
File
      isPackage : Boolean
[唯讀] 指出參考的目錄是否為套件。
File
      isSymbolicLink : Boolean
[唯讀] 指出參考是否為符號連結。
File
      lineEnding : String
[靜態] [唯讀] 主機作業系統使用的行末字元序列。
File
 InheritedmodificationDate : Date
[唯讀] 本機磁碟上最後修改檔案的日期。
FileReference
 Inheritedname : String
[唯讀] 本機磁碟上的檔案名稱。
FileReference
      nativePath : String
主機作業系統表示中的完整路徑。
File
      parent : File
[唯讀] 包含這個 File 物件所參考檔案或目錄的目錄。
File
      permissionStatus : String
[靜態] [唯讀] 判斷應用程式是否已獲得存取檔案系統的權限。
File
      preventBackup : Boolean
指出執行階段是否防止這個 File 物件備份到雲端。
File
      separator : String
[靜態] [唯讀] 主機作業系統的路徑組件分隔字元。
File
 Inheritedsize : Number
[唯讀] 本機磁碟上的檔案大小,以位元組為單位。
FileReference
      spaceAvailable : Number
[唯讀] 此 File 位置上的可用空間 (以位元組為單位)。
File
      systemCharset : String
[靜態] [唯讀] 主機作業系統所使用的預設編碼。
File
 Inheritedtype : String
[唯讀] 檔案類型。
FileReference
      url : String
這個檔案路徑的 URL。
File
      userDirectory : File
[靜態] [唯讀] 使用者的目錄。
File
公用方法
 方法定義自
  
    File(path:String = null)
File 類別的建構函數。
File
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。
EventDispatcher
 Inherited
browse(typeFilter:Array = null):Boolean
顯示檔案瀏覽對話方塊,讓使用者選取要上傳的檔案。
FileReference
  
顯示目錄選擇器對話方塊,讓使用者選取目錄。
File
  
    browseForOpen(title:String, typeFilter:Array = null):void
顯示「開啟檔案」對話方塊,讓使用者選取要開啟的檔案。
File
  
    browseForOpenMultiple(title:String, typeFilter:Array = null):void
顯示「開啟檔案」對話方塊,讓使用者選取一個或多個要開啟的檔案。
File
  
    browseForSave(title:String):void
顯示「儲存檔案」對話方塊,讓使用者選取檔案目的地。
File
  
    cancel():void
[覆寫] 取消任何待處理的非同步作業。
File
  
    canonicalize():void
標準化 File 路徑。
File
  
    clone():File
傳回這個 File 物件的副本。
File
  
    copyTo(newLocation:FileReference, overwrite:Boolean = false):void
將這個 File 物件所指定之位置上的檔案或目錄複製到 newLocation 參數所指定的位置。
File
  
    copyToAsync(newLocation:FileReference, overwrite:Boolean = false):void
開始將這個 File 物件所指定位置上的檔案或目錄複製到 destination 參數指定的位置。
File
  
建立指定的目錄和任何必要的上層目錄。
File
  
[靜態] 傳回新暫存目錄的參考。
File
  
[靜態] 傳回新暫存檔案的參考。
File
  
    deleteDirectory(deleteDirectoryContents:Boolean = false):void
刪除目錄。
File
  
    deleteDirectoryAsync(deleteDirectoryContents:Boolean = false):void
以非同步方式刪除目錄。
File
  
    deleteFile():void
刪除檔案。
File
  
以非同步方式刪除檔案。
File
 Inherited
會將事件傳送到事件流程。
EventDispatcher
 Inherited
download(request:URLRequest, defaultFileName:String = null):void
會開啟對話方塊,讓使用者能從遠端伺服器下載檔案。
FileReference
  
傳回對應於這個 File 物件所代表目錄中之檔案和目錄的 File 物件陣列。
File
  
以非同步方式擷取對應於這個 File 物件所代表目錄內容的 File 物件陣列。
File
  
    getRelativePath(ref:FileReference, useDotDot:Boolean = false):String
找出兩個 File 路徑之間的相對路徑。
File
  
[靜態] 傳回 File 物件的陣列,並列出檔案系統根目錄。
File
 Inherited
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。
EventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
開始載入使用者所選取的本機檔案。
FileReference
  
    moveTo(newLocation:FileReference, overwrite:Boolean = false):void
將這個 File 物件所指定位置上的檔案或目錄移至 destination 參數指定的位置。
File
  
    moveToAsync(newLocation:FileReference, overwrite:Boolean = false):void
開始將這個 File 物件所指定位置上的檔案或目錄移至 newLocation 參數指定的位置。
File
  
    moveToTrash():void
將檔案或目錄移至垃圾筒。
File
  
以非同步方式,將檔案或目錄移至資源回收筒。
File
  
在由作業系統註冊用來開啟此檔案類型的應用程式中開啟檔案。
File
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
會從 EventDispatcher 物件移除偵聽程式。
EventDispatcher
  
[覆寫] 要求權限以存取檔案系統。
File
  
    resolvePath(path:String):File
根據 path 參數 (字串),使用此 File 物件路徑的相對路徑來建立新的 File 物件。
File
 Inherited
save(data:*, defaultFileName:String = null):void
開啟對話方塊,讓使用者能夠將檔案儲存至本機檔案系統。
FileReference
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
upload(request:URLRequest, uploadDataFieldName:String = "Filedata", testUpload:Boolean = false):void
開始將檔案上傳到遠端伺服器。
FileReference
 Inherited
不使用任何編碼,起始上傳檔案至 URL。
FileReference
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。
EventDispatcher
事件
 事件 摘要 定義自
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。EventDispatcher
  
    cancel
當待處理的非同步作業取消時傳送。File
  
    complete
當非同步作業完成時傳送。File
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。EventDispatcher
  當目錄清單因為呼叫 getDirectoryListingAsync() 方法變成可供使用時傳送。File
 Inherited當 upload() 或 uploadUnencoded() 方法呼叫嘗試透過 HTTP 存取資料,而且 Adobe AIR 能夠偵測並傳回要求的狀態碼時傳送。FileReference
 Inherited在上傳失敗時傳送,而且 HTTP 狀態碼可用於描述失敗。FileReference
  
    ioError
當非同步檔案作業期間發生錯誤時傳送。File
 Inherited在上傳或下載作業開始時傳送。FileReference
  當應用程式要求權限以存取檔案系統時傳送。File
 Inherited在檔案上傳或下載作業期間定期傳送。FileReference
  當作業違反安全性限制時傳送。File
  
    select
當使用者從檔案或目錄瀏覽對話方塊中選取檔案或目錄時傳送。File
  當使用者從呼叫 browseForOpenMultiple() 方法所開啟的對話方塊中選取檔案時傳送。File
 Inherited在成功上傳後,從伺服器接到資料以後傳送。FileReference
屬性詳細資訊
    

applicationDirectory

屬性
applicationDirectory:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

包含應用程式已安裝檔案的檔案夾。

這個物件的 url 屬性會使用 app URL 配置 (而非 file URL 配置)。這表示 url 字串是以 "app:" 開頭來指定的 (而非 "file:")。此外,如果您建立一個相對於 File.applicationDirectory 目錄的 File 物件 (使用 resolvePath() 方法),該 File 物件的 url 屬性也會使用 app URL 配置。

注意:您無法寫入其路徑是使用 app: URL 配置的檔案或目錄。您也無法刪除或建立其路徑是使用 app: URL 配置的檔案或檔案夾。修改應用程式目錄中的內容並非好的做法,基於安全考量,某些平台會封鎖此動作。如果您要儲存應用程式特有的資料,請考慮使用應用程式儲存目錄 (File.applicationStorageDirectory)。如果您想讓應用程式儲存目錄中的任何內容能夠存取應用程式權限的功能 (AIR API),可以使用安全執行程序橋接來公開該功能。

applicationDirectory 屬性提供可跨平台參考應用程式目錄的方法。如果您使用 nativePathurl 屬性設定 File 物件來參考應用程式目錄,則該屬性只會在路徑有效的平台上運作。

在 Android 上,指向應用程式目錄的 File 物件 nativePath 屬性為空白字串。請使用 url 屬性來存取應用程式檔案。



實作
    public static function get applicationDirectory():File

相關 API 元素

    

applicationStorageDirectory

屬性 
applicationStorageDirectory:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

應用程式的私用儲存目錄。

每個 AIR 應用程式都有一個唯一且持續的應用程式儲存目錄,這是在您第一次存取 File.applicationStorageDirectory 時建立的。這個目錄對於每一個應用程式與使用者而言都具有唯一性。這個目錄是可讓您方便地儲存使用者或應用程式特有資料的位置。

解除安裝 AIR 應用程式時,解除安裝程式是否刪除應用程式儲存目錄與其檔案,取決於平台。

這個物件的 url 屬性會使用 app-storage URL 配置 (而非 file URL 配置)。這表示 url 字串是以 "app-storage:" 開頭來指定的 (而非 "file:")。此外,如果您建立一個相對於 File.applicationStoreDirectory 目錄的 File 物件 (使用 resolvePath() 方法),該 File 物件的 url 也會使用 app-storage URL 配置 (如範例所示)。

applicationStorageDirectory 屬性提供可跨平台參考應用程式儲存目錄的方法。如果您使用 nativePathurl 屬性設定 File 物件來參考應用程式儲存目錄,則該屬性只會在路徑有效的平台上運作。

注意 (僅限 Mac OS):為符合 Mac App Store 需求,這個目錄的實體位置已在 AIR 3.2 與 AIR 3.3 之間變更:

  • 3.2 命名空間和更早版本:~/Library/Preferences/appid/Local Store/
  • 3.3 命名空間和更新版本:path/Library/Application Support/appid/Local Store/,其中 path 是 ~/Library/Containers/bundle-id/Data (安全執行程序的環境) 或 ~ (若在安全執行程序環境外執行)



實作
    public static function get applicationStorageDirectory():File

範例  ( 如何使用本範例 )
下列程式碼會建立一個指向應用程式儲存目錄 "images" 子目錄的 File 物件。
import flash.filesystem.File;

var tempFiles:File = File.applicationStorageDirectory;
tempFiles = tempFiles.resolvePath("images/");
trace(tempFiles.url); // app-storage:/images
    

cacheDirectory

屬性 
cacheDirectory:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 3.6

應用程式的快取目錄。

cacheDirectory 屬性提供參考快取目錄的方法。您的應用程式應該將快取目錄用來儲存從伺服器下載的檔案,或是以其他方式重新產生的檔案。您應放入快取目錄的檔案範例包括資料庫快取檔案和可下載的內容,例如雜誌、報紙和地圖應用程式所使用的內容。

如果您使用 nativePathurl 屬性設定 File 物件來參考快取目錄,則該屬性只會在路徑有效的平台上運作。

如果作業系統不支援快取目錄,則 cacheDirectory 為 null



實作
    public static function get cacheDirectory():File
    

desktopDirectory

屬性 
desktopDirectory:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

使用者的桌面目錄。

desktopDirectory 屬性提供可跨平台參考桌面目錄的方法。如果您使用 nativePathurl 屬性設定 File 物件來參考桌面目錄,則該屬性只會在路徑有效的平台上運作。

若作業系統不支援桌面目錄,將改用檔案系統中合適的目錄。

AIR for TV 裝置不具有使用者桌面目錄的概念。因此,desktopDirectory 屬性與 File.userDirectory 屬性參照相同的目錄位置。對於應用程式而言,使用者目錄是唯一的。



實作
    public static function get desktopDirectory():File

範例  ( 如何使用本範例 )
下列程式碼會輸出使用者桌面目錄中包含的檔案和目錄清單。
import flash.filesystem.File;
var desktop:File = File.desktopDirectory;

var files:Array = desktop.getDirectoryListing();

for (var i:uint = 0; i < files.length; i++) {
    trace(files[i].nativePath);
}
    

documentsDirectory

屬性 
documentsDirectory:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

使用者的文件目錄。

在 Windows 上,這是 My Documents 目錄 (例如,C:\Documents and Settings\userName\My Documents)。在 Mac OS 上,預設位置是 /Users/userName/Documents。在 Linux 上,預設位置是 /home/userName/Documents (英文版系統),而且此屬性會遵守 xdg-user-dirs 設定。

documentsDirectory 屬性提供可跨平台參考文件目錄的方法。如果您使用 nativePathurl 屬性設定 File 物件來參考文件目錄,則該屬性只會在路徑有效的平台上運作。

若作業系統不支援文件目錄,將改用檔案系統中合適的目錄。

AIR for TV 裝置不具有使用者文件目錄的概念。因此,documentsDirectory 屬性與 File.userDirectory 屬性參照相同的目錄位置。對於應用程式而言,使用者目錄是唯一的。



實作
    public static function get documentsDirectory():File

範例  ( 如何使用本範例 )
下列程式碼會使用 File.documentsDirectory 屬性和 File.createDirectory() 方法,以確保名為 "AIR Test" 的目錄存在於使用者的文件目錄中。
import flash.filesystem.File;

var directory:File = File.documentsDirectory;
directory = directory.resolvePath("AIR Test");

File.createDirectory(directory);
trace(directory.exists); // true
    

downloaded

屬性 
downloaded:Boolean

語言版本: ActionScript 3.0
執行階段版本: AIR 2

指出參考檔案或目錄是否已經下載 (從網際網路)。

這個屬性只在檔案可標示為已經下載的作業系統上才有意義:

  • Windows XP Service Pack 2 和更新版本,以及在 Windows Vista 上
  • Mac OS 10.5 與更新的版本

在不能標示已下載檔案的系統 (例如 Linux) 上,此屬性沒有意義 (並且設定為 false)。



實作
    public function get downloaded():Boolean
    public function set downloaded(value:Boolean):void

相關 API 元素

    

exists

屬性 
exists:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

指出參考的檔案或目錄是否存在。如果 File 物件指向現有檔案或目錄,則此值為 true,否則為 false



實作
    public function get exists():Boolean

範例  ( 如何使用本範例 )
下列程式碼會建立一個暫存檔案,然後刪除它,並使用 File.exists 屬性檢查該檔案是否存在。
import flash.filesystem.*;

var temp:File = File.createTempFile();
trace(temp.exists); // true
temp.deleteFile();
trace(temp.exists); // false
    

icon

屬性 
icon:Icon  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

包含為檔案所定義之圖示的 Icon 物件。Icon 物件是對應於各種圖示狀態的 BitmapData 物件陣列。在 Linux 上,Icon 物件不包含任何圖示。在 Android 上,icon 屬性為 null



實作
    public function get icon():Icon

範例  ( 如何使用本範例 )
下列程式碼示範如何在 icon 陣列中尋找有最大高度的影像,並將 Bitmap 物件設定為該影像。
import flash.filesystem.File;
import flash.display.*;

var directory:File = File.documentsDirectory;
var bitmaps:Array = directory.icon.bitmaps;
var bmpData:BitmapData = new BitmapData(1, 1);
for (var i:uint = 0; i < bitmaps.length; i++) {
    if (bitmaps[i].height > bmpData.height) {
        bmpData = directory.icon.bitmaps[i];
    }
}
var iconBmp:Bitmap = new Bitmap(bmpData);
您可以將這個 Bitmap 物件新增為顯示物件容器 (如 Sprite 物件或 Flex UIComponent 物件) 的子系。
    

isDirectory

屬性 
isDirectory:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

指出是否參考目錄。如果 File 物件指向目錄,則此值為 true,否則為 false



實作
    public function get isDirectory():Boolean

範例  ( 如何使用本範例 )
下列程式碼會建立指向使用者目錄中之檔案和目錄的 File 物件陣列,然後使用 isDirectory 屬性列出只指向目錄 (而非檔案) 的 File 物件。
import flash.filesystem.*;

var userDirFiles:Array = File.userDirectory.getDirectoryListing();
for (var i:uint = 0; i < userDirFiles.length; i++) {
    if (userDirFiles[i].isDirectory) {
        trace(userDirFiles[i].nativePath);
    }
}    
    

isHidden

屬性 
isHidden:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

指出參考的檔案或目錄是否「隱藏」。如果參考的檔案或目錄是隱藏的,則此值為 true,否則為 false



實作
    public function get isHidden():Boolean

範例  ( 如何使用本範例 )
下列程式碼會建立指向使用者目錄中之檔案和目錄的 File 物件陣列,然後使用 isHidden 屬性列出隱藏的檔案和目錄。
import flash.filesystem.*;

var userDirFiles:Array = File.userDirectory.getDirectoryListing();
for (var i:uint = 0; i < userDirFiles.length; i++) {
    if (userDirFiles[i].isHidden) {
        trace(userDirFiles[i].nativePath);
    }
}    
    

isPackage

屬性 
isPackage:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

指出參考的目錄是否為套件。

如果參考的目錄是套件,則此值為 true,否則為 false。請注意,File 類別不允許直接建立套件。

  • 在 Mac OS 上,目錄可以指定為套件,並在 Finder 中顯示為單一檔案而非目錄。如果參考的目錄是套件,這個屬性會設定為 true,但如果檔案不是目錄、不存在或不是套件,則會設定為 false
  • 在其他作業系統上,這個屬性一定會設定為 false



實作
    public function get isPackage():Boolean
    

isSymbolicLink

屬性 
isSymbolicLink:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

指出參考是否為符號連結。

如果 File 物件是符號連結,則此值為 true,否則為 false。請注意,File 類別不允許直接建立符號連結。

符號連結可讓檔案指向磁碟上的另一個檔案或目錄。儘管相似,但符號連結與 Mac OS 的替身及 Windows 的捷徑不同。替身或捷徑一定會回報為檔案 (而非目錄),而且讀取或寫入替身或捷徑絕不會影響它所指向的原始檔案或目錄。另一方面,符號連結的行為通常與它所指向的檔案或目錄相同。它可以回報為檔案或目錄,而且讀取或寫入符號連結會影響它所指向的原始檔案或目錄,而非符號連結本身。不過,刪除符號連結只會刪除此連結,而非連結的目標。

Mac® OS®、Linux 和 Windows® Vista® 都支援符號連結。此外,在 Windows 上,對於參考連接點 (在 NTFS 檔案系統中使用) 的 File 物件,isSymbolicLink 屬性是設定為 true



實作
    public function get isSymbolicLink():Boolean
    

lineEnding

屬性 
lineEnding:String  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

主機作業系統使用的行末字元序列。

在 Mac OS 和 Linux 上,這是換行字元 (字元碼 0x0A 十六進位值)。在 Windows 上,這是歸位字元 (字元碼 0x0D 十六進位值),後面接著換行字元 (字元碼 0x0A 十六進位值)。



實作
    public static function get lineEnding():String

範例  ( 如何使用本範例 )
下列程式碼會將字串 (str) 寫入文字檔,並使用 File.lineEnding 靜態屬性將所有換行字元 (在程式碼中以規則運算式 /\n/g 表示) 取代為主機作業系統慣用的行末字元。
import flash.filesystem.*;

var str:String = "Hello\n" + 
        "World\n";
str = str.replace(/\n/g, File.lineEnding);
var file:File = File.documentsDirectory.resolvePath("AIR Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeUTF(str);
fileStream.close();
    

nativePath

屬性 
nativePath:String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

主機作業系統表示中的完整路徑。在 Mac OS 和 Linux 上,系統會使用正斜線 (/) 字元做為路徑分隔符號。但在 Windows 中,您可以使用正斜線字元或反斜線 (\) 字元做為路徑分隔符號來「設定」nativePath 屬性,而且 AIR 就會自動將正斜線取代為正確的反斜線字元。

在為了直接設定 nativePath 屬性而寫入程式碼前,請先考慮這樣做是否會產生平台專用的程式碼。例如,像是 "C:\\Documents and Settings\\bob\\Desktop" 的原生路徑僅適用於 Windows。建議您使用下列靜態屬性,因為這些屬性代表常用的目錄並且適用於所有平台:

  • File.applicationDirectory
  • File.applicationStorageDirectory
  • File.desktopDirectory
  • File.documentsDirectory
  • File.userDirectory

您可以使用 resolvePath() 方法取得這些目錄的相對路徑。

一些 Flex API (例如 SWFLoader 類別的 source 屬性) 使用 URL (File 物件的 url 屬性),而不是原生路徑 (nativePath 屬性)。



實作
    public function get nativePath():String
    public function set nativePath(value:String):void

擲回值
ArgumentError — 路徑的語法無效。
 
SecurityError — 呼叫者不在應用程式安全執行程序中。

範例  ( 如何使用本範例 )
下列程式碼說明 File 物件 nativePath 屬性和 url 屬性之間的差異。註解說明 Windows 電腦範例上的結果。
import flash.filesystem.File;

var docs:File = File.documentsDirectory;
trace(docs.nativePath); // C:\Documents and Settings\turing\My Documents
trace(docs.url); // file:///C:/Documents%20and%20Settings/turing/My%20Documents
    

parent

屬性 
parent:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

包含這個 File 物件所參考檔案或目錄的目錄。

如果檔案或目錄不存在,parent 屬性仍然會傳回指向包含目錄的 File 物件,即使該目錄不存在。

這個屬性與 resolvePath("..") 的傳回值完全相同,唯一的不同是根目錄的父輩為 null



實作
    public function get parent():File

範例  ( 如何使用本範例 )
下列指令碼會使用 parent 屬性顯示包含暫存檔案的目錄。
import flash.filesystem.File;

var tempFile:File = File.createTempDirectory();
trace(tempFile.parent.nativePath);
tempFile.deleteFile();
    

permissionStatus

屬性 
permissionStatus:String  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 24.0

判斷應用程式是否已獲得存取檔案系統的權限。



實作
    public static function get permissionStatus():String

相關 API 元素

    

preventBackup

屬性 
preventBackup:Boolean

語言版本: ActionScript 3.0
執行階段版本: AIR 3.6

指出執行階段是否防止這個 File 物件備份到雲端。

如果這個屬性設定為 true,則不會在提供這項服務的平台上自動備份至雲端。這個屬性的預設值為 false。



實作
    public function get preventBackup():Boolean
    public function set preventBackup(value:Boolean):void
    

separator

屬性 
separator:String  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

主機作業系統的路徑組件分隔字元。

在 Mac OS 和 Linux 上,這是正斜線 (/) 字元。在 Windows 上,這是反斜線 (\) 字元。

注意:在字串常值中使用反斜線字元時,請記得輸入兩次字元 (如 "directory\\file.ext")。字串常值中的每對反斜線各代表字串中的一個反斜線。



實作
    public static function get separator():String

範例  ( 如何使用本範例 )
下列程式碼會使用 getRelativePath() 方法取得目錄和檔案之間的相對路徑。然後程式碼會使用 File.separator 靜態屬性,將路徑中的正斜線 (/) 字元取代為作業系統使用的分隔字元,這在 Windows 上是反斜線字元 (\),而在其他作業系統上則是正斜線字元。
import flash.filesystem.File;

var directory:File = File.documentsDirectory.resolvePath("Apollo Test");
var file:File = File.documentsDirectory.resolvePath("Apollo Test/employees/bob/test.txt");

var relativePath:String = directory.getRelativePath(file); // employees/bob/test.txt
relativePath = relativePath.replace(/\//g, File.separator);
trace(relativePath); 
在這個範例中,replace() 方法會使用規則運算式 /\//g,以符合所有正斜線字元。
    

spaceAvailable

屬性 
spaceAvailable:Number  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.1

此 File 位置上的可用空間 (以位元組為單位)。

如果 File 物件參考目錄,則 spaceAvailable 會指出目錄中檔案可使用的空間。如果 File 物件參考檔案,則 spaceAvailable 會指出檔案可成長的空間。如果檔案位置不存在,spaceAvailable 會設定為 0。如果 File 物件參考符號連結,則 spaceAvailable 會指出符號連結所指向位置的可用空間。

目錄或檔案的可用空間通常與包含目錄或檔案之磁碟上的可用空間相同。不過,可用空間可能會將帳戶配額和每個目錄限制納入考量。

將檔案或目錄加入至磁碟,通常需要比檔案實際大小或目錄內容大小更大的空間。例如,作業系統可能需要更多空間來儲存索引資訊。必要的磁區也可能會使用額外的空間。此外,可用空間會動態變更。因此,您無法預期為儲存檔案配置「所有」空間。



實作
    public function get spaceAvailable():Number
    

systemCharset

屬性 
systemCharset:String  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

主機作業系統所使用的預設編碼。

可能值包含 "windows-1252""shift-jis""cn-gb""iso-8859-1" 等等。如需完整清單,請參閱「支援的字元集」

當您使用 FileStream 類別的 readMultiByte()writeMultiByte() 方法時,可以使用此值。



實作
    public static function get systemCharset():String

相關 API 元素


範例  ( 如何使用本範例 )
下列程式碼會開啟檔案 (在使用者文件目錄的 AIR Test 子目錄中的 test.txt 檔案),然後使用 File.systemCharset 靜態屬性做為 FileStream 物件 readMultiByte() 方法呼叫的 charSet 參數。
import flash.filesystem.File;

var file:File = File.documentsDirectory.resolvePath("AIR Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var str:String = fileStream.readMultiByte(file.size, File.systemCharset);
trace(str);    
    

url

屬性 
url:String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

這個檔案路徑的 URL。

如果這是應用程式儲存目錄中某個路徑的參考,則 URL 配置就是 "app-storage";如果這是應用程式目錄中某個路徑的參考,則 URL 配置就是 "app";否則,配置就是 "file"

「指定」值給 url 屬性時,您可以使用空格字元 (而非 "%20");AIR 會自動將字串編碼 (例如,將空格轉換為 "%20")。



實作
    public function get url():String
    public function set url(value:String):void

擲回值
ArgumentError — URL 語法無效。
 
SecurityError — 呼叫者不在應用程式安全執行程序中。

相關 API 元素


範例  ( 如何使用本範例 )
下列程式碼說明 File 物件 nativePath 屬性和 url 屬性之間的差異。註解說明 Windows 電腦範例上的結果。
import flash.filesystem.File;

var docs:File = File.documentsDirectory;
trace(docs.nativePath); // C:\Documents and Settings\turing\My Documents
trace(docs.url); // file:///C:/Documents%20and%20Settings/turing/My%20Documents
    

userDirectory

屬性 
userDirectory:File  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

使用者的目錄。

在 Windows 上,這是 My Documents 目錄的父輩 (例如,C:\Documents and Settings\userName)。在 Mac OS 上,它是 /Users/userName. 在 Linux 上,它是 /home/userName。

userDirectory 屬性提供可跨平台參考使用者目錄的方法。如果您直接設定 File 物件的 nativePathurl 屬性,則該屬性只會在路徑有效的平台上運作。

若作業系統不支援使用者目錄,將改用檔案系統中合適的目錄。

在 AIR for TV 裝置上,userDirectory 屬性參照對於應用程式而言是唯一的使用者目錄。



實作
    public static function get userDirectory():File

範例  ( 如何使用本範例 )
下列程式碼會輸出使用者目錄根層級中包含的檔案和目錄清單:
import flash.filesystem.File;

var files:Array = File.userDirectory.listDirectory();
for (var i:uint = 0; i < files.length; i++) {
    trace(files[i].nativePath);
}
建構函式詳細資料
    

File

()建構函式
public function File(path:String = null)

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

File 類別的建構函數。

如果您傳遞 path 引數,File 物件就會指向指定路徑,而且會傳送 nativePath 屬性和 url 屬性以反映該路徑。

雖然您可以傳遞 path 引數來指定檔案路徑,但請先考慮這樣做是否會產生平台專用的程式碼。例如,像是 "C:\\Documents and Settings\\bob\\Desktop" 的原生路徑或 "file:///C:/Documents%20and%20Settings/bob/Desktop" 這類型的 URL 僅適用於 Windows。建議您使用下列靜態屬性,因為這些屬性代表常用的目錄並且適用於所有平台:

  • File.applicationDirectory
  • File.applicationStorageDirectory
  • File.desktopDirectory
  • File.documentsDirectory
  • File.userDirectory

接著,您可以使用 resolvePath() 方法取得這些目錄的相對路徑。例如,下列程式碼會將 File 物件指向應用程式儲存目錄中的 settings.xml 檔案:

var file:File = File.applicationStorageDirectory.resolvePath("settings.xml");

重要:如果您在 path 參數中傳遞 URL 字串,會將 URL 解碼以解析檔案路徑。例如,new File("file:///c:/test/demo%20file%201%2e0.txt") 陳述式會使用原生路徑 "c:\test\demo file 1.0.txt" 建立 File 物件。(URL 會使用 file:、app: 或 app-storage: scheme 前置詞)。不過,如果省略有效的 URL 前置詞,會將路徑字串視為原生路徑,並且不會執行解碼。在驗證來自可能不受信任之來源的路徑時,您必須將此行為列入考量。如果直接驗證輸入字串,URL 解碼可能會允許攻擊者略過您的驗證檢查。總是驗證實體化之檔案物件的最後路徑:

     var file:File = new File( taintedString );
     validate( file.nativePath ); //where validate() is your path validation function
     

參數
path:String (default = null) — 檔案的路徑。您可以使用 URL 或原生路徑 (平台特有) 標記法來指定路徑。

如果您指定 URL,可以使用下列任何 URL 配置:fileappapp-storage。對於使用 URL 標記法的 path 參數,有效值如下:

  • "app:/DesktopPathTest.xml"
  • "app-storage:/preferences.xml"
  • "file:///C:/Documents%20and%20Settings/bob/Desktop" (Bob 的 Windows 電腦桌面)
  • "file:///Users/bob/Desktop" (Bob 的 Mac 電腦桌面)

appapp-storage URL 配置十分有用,因為它們可以指向所有檔案系統上的有效檔案。但在其他兩個使用 file URL 配置指向使用者桌面目錄的範例中,比較好的方法是「不」傳遞 path 引數給 File() 建構函式,然後指定 File.desktopDirectory 給 File 物件,因為這個方法可存取與平台和使用者無關的桌面目錄。

如果您指定原生路徑,在 Windows 上可以在此引數中使用反斜線 ("\") 字元或正斜線 ("/") 字元做為路徑分隔符號;在 Mac OS 和 Linux 上則使用正斜線 ("/") 字元。對於使用原生路徑標記法的 path 參數,有效值如下:

  • "C:/Documents and Settings/bob/Desktop"
  • "/Users/bob/Desktop"

但在這兩個範例中,您「不」應該傳遞 path 引數給 File() 建構函式,然後指定 File.desktopDirectory 給 File 物件,因為這個方法可存取與平台和使用者無關的桌面目錄。


擲回值
ArgumentError path 參數的語法無效。

相關 API 元素

方法詳細資訊

    browseForDirectory

()方法
public function browseForDirectory(title:String):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

顯示目錄選擇器對話方塊,讓使用者選取目錄。當使用者選取目錄時,會傳送 select 事件。select 事件的 target 屬性就是指向所選取目錄的 File 物件。

目錄選擇器對話方塊不一定會顯示在由其他視窗所「擁有」的視窗前面 (owner 屬性不是 Null 的視窗)。若要避免發生視窗排序問題,請在呼叫此方法之前隱藏擁有的視窗。

注意:在 Android 裝置上,不支援 browseForDirectory()。File 物件會立即傳送 cancel 事件。

參數

title:String — 在對話方塊標題列中顯示的字串。


事件
cancel:Event — 當使用者在「開啟檔案」對話方塊中按一下「取消」按鈕時傳送。
 
select:Event — 當使用者選取目錄並關閉「目錄選擇器」對話方塊時傳送。
 
ioError:IOErrorEvent — 此平台上不支援瀏覽作業。

擲回值
IllegalOperationError — 瀏覽作業 (browseForOpen()、browseForOpenMultiple()、browseForSave()、browseForDirectory()) 目前正在執行。
 
SecurityError — 應用程式不具有必要的權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會使用 File.browseForDirectory() 方法讓使用者選取目錄。選取此目錄時,程式碼會在 trace() 輸出中列出所選取目錄的內容。
import flash.filesystem.File;
import flash.events.Event;

var directory:File = File.documentsDirectory;

try
{
    directory.browseForDirectory("Select Directory");
    directory.addEventListener(Event.SELECT, directorySelected);
}
catch (error:Error)
{
    trace("Failed:", error.message);
}

function directorySelected(event:Event):void 
{
    directory = event.target as File;
    var files:Array = directory.getDirectoryListing();
    for(var i:uint = 0; i < files.length; i++)
    {
        trace(files[i].name);
    }
}

    browseForOpen

()方法 
public function browseForOpen(title:String, typeFilter:Array = null):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

顯示「開啟檔案」對話方塊,讓使用者選取要開啟的檔案。

當使用者選取檔案時,會傳送 select 事件。select 事件的 target 屬性就是指向所選取檔案的 File 物件。

「開啟檔案」對話方塊不一定會顯示在由其他視窗所「擁有」的視窗前面 (owner 屬性不是 Null 的視窗)。若要避免發生視窗排序問題,請在呼叫此方法之前隱藏擁有的視窗。

注意:在 Android 裝置上,無法設定檔案對話方塊標題。title 參數會遭到忽略。

參數

title:String — 在對話方塊標題列中顯示的字串。
 
typeFilter:Array (default = null) — FileFilter 實體的陣列,用來篩選顯示於對話方塊內的檔案。 如果省略此參數,便會顯示全部檔案。 如需詳細資訊,請參閱 FileFilter 類別。


事件
cancel:Event — 當使用者在「開啟檔案」對話方塊中按一下「取消」按鈕時傳送。
 
select:Event — 當使用者選取檔案並關閉「開啟檔案」對話方塊時傳送。
 
ioError:IOErrorEvent — 此平台上不支援瀏覽作業。

擲回值
IllegalOperationError — 瀏覽作業 (browseForOpen()、browseForOpenMultiple()、browseForSave()、browseForDirectory()) 目前正在執行。
 
SecurityError — 應用程式不具有必要的權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會使用 File.browseForOpen() 方法讓使用者選擇文字檔。選取此檔案時,程式碼會將檔案資料讀入字串。
import flash.filesystem.*;
import flash.events.Event;
import flash.net.FileFilter;

var fileToOpen:File = new File();
var txtFilter:FileFilter = new FileFilter("Text", "*.as;*.css;*.html;*.txt;*.xml");

try 
{
    fileToOpen.browseForOpen("Open", [txtFilter]);
    fileToOpen.addEventListener(Event.SELECT, fileSelected);
}
catch (error:Error)
{
    trace("Failed:", error.message);
}

function fileSelected(event:Event):void 
{
    var stream:FileStream = new FileStream();
    stream.open(event.target, FileMode.READ);
    var fileData:String = stream.readUTFBytes(stream.bytesAvailable);
    trace(fileData);
}

    browseForOpenMultiple

()方法 
public function browseForOpenMultiple(title:String, typeFilter:Array = null):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

顯示「開啟檔案」對話方塊,讓使用者選取一個或多個要開啟的檔案。

當使用者選取檔案時,會傳送 selectMultiple 事件。select 事件的 target 屬性就是這個 File 物件。這個 File 物件與含有 browseForOpenMultiple() 方法的 browseForOpen() 不同,它不會更新以參考任何所選的檔案。相反地,產生的 selectMultiple 事件會包含所選檔案的陣列。

「開啟檔案」對話方塊不一定會顯示在由其他視窗所「擁有」的視窗前面 (owner 屬性不是 Null 的視窗)。若要避免發生視窗排序問題,請在呼叫此方法之前隱藏擁有的視窗。

注意:在 Android 裝置上,無法設定檔案對話方塊標題。title 參數會遭到忽略。

參數

title:String — 在對話方塊標題列中顯示的字串。
 
typeFilter:Array (default = null) — FileFilter 實體的陣列,用來篩選顯示於對話方塊內的檔案。 如果省略此參數,便會顯示全部檔案。 如需詳細資訊,請參閱 FileFilter 類別。


事件
cancel:Event — 當使用者在「開啟檔案」對話方塊中按一下「取消」按鈕時傳送。
 
selectMultiple:FileListEvent — 當使用者選取檔案並關閉「開啟檔案」對話方塊時傳送。
 
ioError:IOErrorEvent — 此平台上不支援瀏覽作業。

擲回值
IllegalOperationError — 瀏覽作業 (browseForOpen()、browseForOpenMultiple()、browseForSave()、browseForDirectory()) 目前正在執行。
 
SecurityError — 應用程式不具有必要的權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會使用 File.browseForOpenMultiple() 方法讓使用者選擇多個檔案。選取這些檔案時,程式碼會輸出選取檔案的路徑。
import flash.filesystem.*;
import flash.events.FileListEvent;

var docsDir:File = File.documentsDirectory;
try
{
    docsDir.browseForOpenMultiple("Select Files");
    docsDir.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
}
catch (error:Error)
{
    trace("Failed:", error.message);
}

function filesSelected(event:FileListEvent):void 
{
    for (var i:uint = 0; i < event.files.length; i++) 
    {
        trace(event.files[i].nativePath);
    }
}

    browseForSave

()方法 
public function browseForSave(title:String):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

顯示「儲存檔案」對話方塊,讓使用者選取檔案目的地。

當使用者選取檔案時,會傳送 select 事件。select 事件的 target 屬性就是指向所選取 Save 目的地的 File 物件。

「儲存檔案」對話方塊不一定會顯示在由其他視窗所「擁有」的視窗前面 (owner 屬性不是 Null 的視窗)。若要避免發生視窗排序問題,請在呼叫此方法之前隱藏擁有的視窗。

注意:在 Android 裝置上,無法設定檔案對話方塊標題。title 參數會遭到忽略。

參數

title:String — 在對話方塊標題列中顯示的字串。


事件
cancel:Event — 當使用者在「儲存檔案」對話方塊中按一下「取消」按鈕時傳送。
 
select:Event — 當使用者選取檔案並關閉「儲存檔案」對話方塊時傳送。
 
ioError:IOErrorEvent — 此平台上不支援瀏覽作業。

擲回值
IllegalOperationError — 瀏覽作業 (browseForOpen()、browseForOpenMultiple()、browseForSave()、browseForDirectory()) 目前正在執行。
 
SecurityError — 應用程式不具有必要的權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會使用 File.browseForSave() 方法,讓使用者選取儲存檔案的路徑。選取這些檔案時,程式碼會將資料儲存至選取的檔案路徑。
import flash.filesystem.*;
import flash.events.Event;

var docsDir:File = File.documentsDirectory;
try
{
    docsDir.browseForSave("Save As");
    docsDir.addEventListener(Event.SELECT, saveData);
}
catch (error:Error)
{
    trace("Failed:", error.message);
}

function saveData(event:Event):void 
{
    var newFile:File = event.target as File;
    var str:String = "Hello.";
    if (!newFile.exists)
    {
        var stream:FileStream = new FileStream();
        stream.open(newFile, FileMode.WRITE);
        stream.writeUTFBytes(str);
        stream.close();
    }
}

    cancel

()方法 
override public function cancel():void

執行階段版本: AIR 1.0

取消任何待處理的非同步作業。

    canonicalize

()方法 
public function canonicalize():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

標準化 File 路徑。

如果 File 物件代表現有檔案或路徑,則標準化會調整該路徑以符合實際檔案或目錄名稱的大小寫。如果 File 物件是符號連結,則標準化會調整該路徑以符合連結指向的檔案或目錄,不論所指向的檔案或目錄是否存在。在區分大小寫的檔案系統上 (例如 Linux),同時存在多個名稱僅大小寫不同的檔案時,canonicalize() 方法就會調整路徑來對應找到的第一個檔案 (尋找的順序由檔案系統決定)。

此外,在 Windows 上,標準化會將短檔案名稱轉換成長檔案名稱。


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 canonicalize() 方法找出目錄名稱正確的大小寫。執行這個範例之前,請先在電腦桌面上建立一個名為 AIR Test 的目錄。
import flash.filesystem.*;

var path:File = File.desktopDirectory.resolvePath("air test");
trace(path.nativePath); 
path.canonicalize();
trace(path.nativePath); // ...\AIR Test


下列程式碼示範如何使用 canonicalize() 方法,根據目錄簡短名稱找出 Windows 目錄完整名稱。這個範例假設 C: 磁碟機根目錄有 AIR Test 目錄,而且系統已指定簡短名稱 AIR~1 給該目錄。
import flash.filesystem.*;

var path:File = new File();
path.nativePath = "C:\\AIR~1";
path.canonicalize();
trace(path.nativePath); // C:\AIR Test

    clone

()方法 
public function clone():File

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

傳回這個 File 物件的副本。不會複製事件註冊。

注意:這個方法會複製檔案本身。它只會複製 ActionScript File 物件實體。若要複製檔案,請使用 copyTo() 方法。

傳回值
File

    copyTo

()方法 
public function copyTo(newLocation:FileReference, overwrite:Boolean = false):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

將這個 File 物件所指定之位置上的檔案或目錄複製到 newLocation 參數所指定的位置。複製程序會建立任何必要的上層目錄 (如果可能)。使用 copyTo() 覆寫檔案時,也會覆寫檔案特質。

參數

newLocation:FileReference — 新檔案的目標位置。請注意,這個 File 物件指定產生的 (複製的) 檔案或目錄,而非包含目錄的路徑。
 
overwrite:Boolean (default = false) — 如果為 false,則在 target 參數所指定的檔案已存在時,複製會失敗。如果為 true,則作業會覆寫同名的現有檔案或目錄。


擲回值
IOError — 來源不存在,或者目的地存在而且 overwritefalse,或者來源無法複製到目標,或者來源和目的地參考相同的檔案或資料夾而且 overwrite 設定為 true。在 Windows 上,無法複製開啟的檔案或包含開啟檔案的目錄。
 
SecurityError — 應用程式不具有寫入目標的必要權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 copyTo() 方法複製檔案。執行此程式碼之前,請先在電腦文件目錄的 AIR Test 子目錄中建立 test1.txt 檔案。產生的複製檔案命名為 test2.txt,而且它也是在 AIR Test 子目錄中。當您將 overwrite 參數設定為 true 時,此作業會覆寫任何現有的 test2.txt 檔案。
import flash.filesystem.File;
import flash.events.Event;

var sourceFile:FileReference = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("AIR Test/test1.txt");
var destination:FileReference = File.documentsDirectory;
destination = destination.resolvePath("AIR Test/test2.txt");

if (sourceFile.copyTo(destination, true)) {
    trace("Done.");
}

下列程式碼示範如何使用 copyTo() 方法複製檔案。執行此程式碼之前,請先在電腦主目錄的 AIR Test 子目錄中建立 test1.txt 檔案。產生的複製檔案命名為 test2.txt。trycatch 陳述式顯示如何回應錯誤。
import flash.filesystem.File;

var sourceFile:File = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("AIR Test/test1.txt");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("AIR Test/test2.txt");

try 
{
    sourceFile.copyTo(destination, true);
}
catch (error:Error)
{
    trace("Error:", error.message);
}

    copyToAsync

()方法 
public function copyToAsync(newLocation:FileReference, overwrite:Boolean = false):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

開始將這個 File 物件所指定之位置上的檔案或目錄複製到 destination 參數所指定的位置。

完成時,會傳送 complete 事件 (成功) 或 ioError 事件 (不成功)。複製程序會建立任何必要的上層目錄 (如果可能)。

參數

newLocation:FileReference — 新檔案的目標位置。請注意,這個 File 物件指定產生的 (複製的) 檔案或目錄,而非包含目錄的路徑。
 
overwrite:Boolean (default = false) — 如果為 false,則在 target 檔案所指定的檔案已存在時,複製會失敗。如果為 true,則作業會覆寫任何同名的現有檔案或目錄。


事件
complete:Event — 當檔案或目錄已經成功複製時傳送。
 
ioError:IOErrorEvent — 來源不存在,或者目的地存在而且 overwritefalse,或者來源無法複製到目標,或者來源和目的地參考相同的檔案或資料夾而且 overwrite 設定為 true。在 Windows 上,無法複製開啟的檔案或包含開啟檔案的目錄。

擲回值
SecurityError — 應用程式不具有寫入目標的必要權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 copyToAsync() 方法複製檔案。執行此程式碼之前,請務必先在電腦文件目錄的 AIR Test 子目錄中建立 test1.txt 檔案。產生的複製檔案命名為 test2.txt,而且它也是在 AIR Test 子目錄中。當您將 overwrite 參數設定為 true 時,此作業會覆寫任何現有的 test2.txt 檔案。
import flash.filesystem.File;
import flash.events.Event;

var sourceFile:File = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("AIR Test/test1.txt");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("AIR Test/test2.txt");

sourceFile.copyToAsync(destination, true);
sourceFile.addEventListener(Event.COMPLETE, fileCopiedHandler);

function fileCopiedHandler(event:Event):void {
    trace("Done.");
}

    createDirectory

()方法 
public function createDirectory():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

建立指定的目錄和任何必要的上層目錄。如果目錄已存在,則不會採取動作。


擲回值
IOError — 目錄不存在且無法建立。
 
SecurityError — 應用程式不具有必要的權限。

範例  ( 如何使用本範例 )

下列程式碼會將桌面上一個名為 test.txt 的檔案移至文件目錄的 AIR Test 子目錄。createDirectory() 方法的呼叫可確保 AIR Test 目錄在檔案移動之前已存在。
import flash.filesystem.*;

var source:File = File.desktopDirectory.resolvePath("test.txt");
var target:File = File.documentsDirectory.resolvePath("AIR Test/test.txt");
var targetParent:File = target.parent;
targetParent.createDirectory();
source.moveTo(target, true);

    createTempDirectory

()方法 
public static function createTempDirectory():File

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

傳回新暫存目錄的參考。這是系統暫存目錄路徑中的新目錄。

這個方法可讓您識別新的唯一目錄,免除查詢系統以檢查目錄是否新且唯一的步驟。

關閉應用程式之前,您可能要刪除暫存目錄,因為某些裝置不會自動刪除暫存目錄。

傳回值
File — 參考新暫存目錄的 File 物件。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼使用 createTempFile() 方法取得新暫存目錄的參考。
import flash.File;

var temp:File = File.createTempDirectory();
trace(temp.nativePath);
每次執行此程式碼時,都會建立新 (唯一的) 檔案。

    createTempFile

()方法 
public static function createTempFile():File

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

傳回新暫存檔案的參考。這是系統暫存目錄路徑中的新檔案。

這個方法可讓您識別新的唯一檔案,免除查詢系統以檢查檔案是否新且唯一的步驟。

在關閉應用程式之前,您可能要刪除暫存檔案,因為它不會自動被刪除。

傳回值
File — 參考新暫存檔案的 File 物件。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼使用 createTempFile() 方法取得新暫存檔案的參考。
import flash.File;

var temp:File = File.createTempFile();
trace(temp.nativePath);
每次執行此程式碼時,都會建立新 (唯一的) 檔案。

    deleteDirectory

()方法 
public function deleteDirectory(deleteDirectoryContents:Boolean = false):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

刪除目錄。如果這個 File 實際上是目錄的符號連結,系統就會移除此連結,而非目錄。

參數

deleteDirectoryContents:Boolean (default = false) — 指定是否要刪除包含檔案或子目錄的目錄。值為 false 時,如果目錄包含檔案或子目錄,呼叫這個方法就會擲回例外。


擲回值
IOError — 目錄不存在或無法刪除。在 Windows 上無法刪除包含開啟檔案的目錄。
 
SecurityError — 應用程式不具有刪除目錄的必要權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會建立一個空白目錄,然後使用 deleteDirectory() 方法刪除該目錄。
import flash.filesystem.File;

var directory:File = File.documentsDirectory.resolvePath("Empty Junk Directory/");
File.createDirectory(directory);
trace(directory.exists); // true
directory.deleteDirectory();
trace(directory.exists); // false

    deleteDirectoryAsync

()方法 
public function deleteDirectoryAsync(deleteDirectoryContents:Boolean = false):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

以非同步方式刪除目錄。如果這個 File 實際上是目錄的符號連結,系統就會移除此連結,而非目錄。

參數

deleteDirectoryContents:Boolean (default = false) — 指定是否要刪除包含檔案或子目錄的目錄。值為 false 時,如果目錄包含檔案或子目錄,File 物件就會傳送 ioError 事件。


事件
complete:Event — 當目錄已經成功刪除時傳送。
 
ioError:IOErrorEvent — 目錄不存在或無法刪除。在 Windows 上無法刪除包含開啟檔案的目錄。

擲回值
SecurityError — 應用程式不具有刪除目錄的必要權限。

相關 API 元素

    deleteFile

()方法 
public function deleteFile():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

刪除檔案。如果這個 File 實際上是符號連結,系統就會移除此連結,而非目標檔案。


擲回值
IOError — 檔案不存在或無法刪除。在 Windows 上無法刪除目前開啟的檔案。
 
SecurityError — 應用程式不具有刪除檔案的必要權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會建立一個暫存檔,然後呼叫 deleteFile() 方法刪除它。
import flash.filesystem.*;

var file:File = File.createTempFile();
trace(file.exists); // true
file.deleteFile();
trace(file.exists); // false

    deleteFileAsync

()方法 
public function deleteFileAsync():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

以非同步方式刪除檔案。如果這個 File 實際上是符號連結,系統就會移除此連結,而非目標檔案。


事件
complete:Event — 當檔案已經成功刪除時傳送。
 
ioError:IOErrorEvent — 檔案不存在或無法刪除。在 Windows 上無法刪除目前開啟的檔案。

擲回值
SecurityError — 應用程式不具有刪除檔案的必要權限。

相關 API 元素

    getDirectoryListing

()方法 
public function getDirectoryListing():Array

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

傳回對應於這個 File 物件所代表目錄中之檔案和目錄的 File 物件陣列。這個方法不會探索子目錄的內容。

傳回值
Array — File 物件的陣列。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 getDirectoryListing() 方法列舉使用者目錄的內容。
import flash.filesystem.File;

var directory:File = File.userDirectory;
var list:Array = directory.getDirectoryListing();
for (var i:uint = 0; i < list.length; i++) {
    trace(list[i].nativePath);
}

    getDirectoryListingAsync

()方法 
public function getDirectoryListingAsync():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

以非同步方式擷取對應於這個 File 物件所代表目錄內容的 File 物件陣列。


事件
ioError:ErrorEvent — 您沒有讀取這個目錄的適當權限,或是目錄不存在。
 
directoryListing:FileListEvent — 目錄內容已經成功列舉。contents 事件包含 files 屬性,它是 File 物件的結果陣列。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 getDirectoryListingAsync() 方法列舉使用者目錄的內容。
import flash.filesystem.File;
import flash.events.FileListEvent;

var directory:File = File.userDirectory;
directory.getDirectoryListingAsync();
directory.addEventListener(FileListEvent.DIRECTORY_LISTING, directoryListingHandler);

function directoryListingHandler(event:FileListEvent):void {
    var list:Array = event.files;
    for (var i:uint = 0; i < list.length; i++) {
        trace(list[i].nativePath);
    }
}

    getRelativePath

()方法 
public function getRelativePath(ref:FileReference, useDotDot:Boolean = false):String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

找出兩個 File 路徑之間的相對路徑。

相對路徑是可附加至此參考 (據以解析) 以找出第二個 (參數) 參考的組件清單。使用 "/" 分隔字元傳回相對路徑。

或者,相對路徑也可以包含 ".." 參考,但這種路徑不會跨越顯著的磁碟邊界。

參數

ref:FileReference — 針對其指定路徑的 File 物件。
 
useDotDot:Boolean (default = false) — 指定所產生的相對路徑是否可以使用 ".." 組件。

傳回值
String — 如果可能,則為這個檔案 (或目錄) 與 ref 檔案 (或目錄) 之間的相對路徑;否則為 null

擲回值
ArgumentError — 參考是 null
 
SecurityError — 呼叫者不在應用程式安全執行程序中。

    getRootDirectories

()方法 
public static function getRootDirectories():Array

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

傳回 File 物件的陣列,並列出檔案系統根目錄。

例如,在 Windows 上,這是磁碟清單,如 C: 磁碟機和 D: 磁碟機。此陣列中不包含空白磁碟機,如未插入光碟片的 CD 或 DVD 光碟機。在 Mac OS 和 Linux 中,這個方法一定會傳回電腦的唯一根目錄 (即「/」目錄)

在根目錄無法讀取的檔案系統上 (例如 Android 檔案系統),傳回的 File 物件的屬性不一定會反映真實值。例如,在 Android 上,spaceAvailable 屬性會報告 0。

傳回值
Array — File 物件的陣列,列出根目錄。

範例  ( 如何使用本範例 )

下列程式碼會輸出根目錄清單:
import flash.filesystem.File;
var rootDirs:Array = File.getRootDirectories();

for (var i:uint = 0; i < rootDirs.length; i++) {
    trace(rootDirs[i].nativePath);
}

    moveTo

()方法 
public function moveTo(newLocation:FileReference, overwrite:Boolean = false):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

將這個 File 物件所指定位置上的檔案或目錄移至 destination 參數指定的位置。

若要重新命名檔案,請設定 destination 參數以指向檔案目錄中的路徑,但使用不同的檔案名稱。

移動程序會建立任何必要的上層目錄 (如果可能)。

參數

newLocation:FileReference — 移動動作的目標位置。這個物件指定所產生 (移動後) 檔案或目錄的路徑,而非包含目錄的路徑。
 
overwrite:Boolean (default = false) — 如果為 false,則在 target 檔案已存在時,移動會失敗。如果為 true,則作業會覆寫任何同名的現有檔案或目錄。


擲回值
IOError — 來源不存在,或者目的地存在而且 overwrite 設定為 false,或者來源檔案或目錄無法移至目標位置,或者來源和目的地參考相同的檔案或資料夾而且 overwrite 設定為 true。在 Windows 上,無法移動開啟的檔案或包含開啟檔案的目錄。
 
SecurityError — 應用程式不具有移動檔案的必要權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 moveTo() 方法重新命名檔案。原始檔案名稱為 test1.txt,而產生的檔案名稱為 test2.txt。因為來源和目的地 File 物件都指向相同的目錄 (使用者文件目錄的 Apollo Test 子目錄),所以 moveTo() 方法會重新命名檔案 (而不會將它移至新目錄)。執行此程式碼之前,請先在電腦文件目錄的 AIR Test 子目錄中建立 test1.txt 檔案。當您將 overwrite 參數設定為 true 時,此作業會覆寫任何現有的 test2.txt 檔案。
import flash.filesystem.File;
import flash.events.Event;

var sourceFile:File = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("AIR Test/test1.txt");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("Apollo Test/test2.txt");

try  
{
    sourceFile.moveTo(destination, true);
}
catch (error:Error)
{
    trace("Error:" + error.message);
}

下列程式碼示範如何使用 moveTo() 方法移動檔案。原始檔案是使用者文件目錄 Apollo Test 子目錄中的 test1.txt 檔案,而此方法會將該檔案移至 Results 子目錄中。執行此程式碼之前,請先在電腦主目錄的 AIR Test 子目錄中建立 test1.txt 檔案。trycatch 陳述式顯示如何回應錯誤。
import flash.filesystem.File;

var sourceFile:File = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("AIR Test/test1.txt");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("AIR Test/Results/test1.txt");

try 
{
    sourceFile.moveTo(destination, true);
}
catch (error:Error)
{
    trace("Error:" + error.message);
}

    moveToAsync

()方法 
public function moveToAsync(newLocation:FileReference, overwrite:Boolean = false):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

開始將這個 File 物件所指定之位置上的檔案或目錄移至 newLocation 參數所指定的位置。

若要重新命名檔案,請設定 destination 參數以指向檔案目錄中的路徑,但使用不同的檔案名稱。

移動程序會建立任何必要的上層目錄 (如果可能)。

參數

newLocation:FileReference — 移動動作的目標位置。這個物件指定所產生 (移動後) 檔案或目錄的路徑,而非包含目錄的路徑。
 
overwrite:Boolean (default = false) — 如果為 false,則在 target 檔案已存在時,移動會失敗。如果為 true,則作業會覆寫任何同名的現有檔案或目錄。


事件
complete:Event — 當檔案或目錄已經成功移動時傳送。
 
ioError:IOErrorEvent — 來源不存在,或者目的地存在而且 overwritefalse;或者來源無法移至目標;或者來源和目的地參考相同的檔案或資料夾而且 overwrite 設定為 true。在 Windows 上,無法移動開啟的檔案或包含開啟檔案的目錄。

擲回值
SecurityError — 應用程式不具有移動檔案的必要權限。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何使用 moveToAsync() 方法重新命名檔案。原始檔案名稱為 test1.txt,而產生的名稱為 test2.txt。因為來源和目的地 File 物件都指向相同的目錄 (使用者文件目錄的 Apollo Test 子目錄),所以 moveToAsync() 方法會重新命名檔案 (而不會將它移至新目錄)。執行此程式碼之前,請先在電腦文件目錄的 Apollo Test 子目錄中建立 test1.txt 檔案。當您將 overwrite 參數設定為 true 時,此作業會覆寫任何現有的 test2.txt 檔案。
import flash.filesystem.File;
import flash.events.Event;

var sourceFile:File = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("Apollo Test/test1.txt");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("Apollo Test/test2.txt");

sourceFile.moveToAsync(destination, true);
sourceFile.addEventListener(Event.COMPLETE, fileMoveCompleteHandler);

function fileMoveCompleteHandler(event:Event):void 
{
    trace("Done.")
}

    moveToTrash

()方法 
public function moveToTrash():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

將檔案或目錄移至垃圾筒。

注意:在不具有可復原資源回收筒功能的作業系統上,將會立即移除檔案。


擲回值
IOError — 作業系統不允許此作業,或是檔案或目錄不存在。在 Windows 上,無法移動開啟的檔案或包含目前開啟檔案的目錄。
 
SecurityError — 應用程式不具有將檔案移至資源回收筒的必要權限。

相關 API 元素

    moveToTrashAsync

()方法 
public function moveToTrashAsync():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

以非同步方式,將檔案或目錄移至資源回收筒。

注意:在不具有可復原資源回收筒功能的作業系統上,將會立即移除檔案。


事件
ioError:IOErrorEvent — 作業系統不允許此作業,或是檔案或目錄不存在。在 Windows 上,無法移動開啟的檔案或包含目前開啟檔案的目錄。
 
complete:Event — 當檔案或目錄已經成功移至垃圾筒時傳送。

擲回值
SecurityError — 應用程式不具有將檔案移至資源回收筒的必要權限。

相關 API 元素

    openWithDefaultApplication

()方法 
public function openWithDefaultApplication():void

語言版本: ActionScript 3.0
執行階段版本: AIR 2

在由作業系統註冊用來開啟此檔案類型的應用程式中開啟檔案。

AIR 拒絕您使用 File.openWithDefaultApplication() 方法開啟特定檔案。在 Windows 中,AIR 會防止您開啟特定檔案類型的檔案 (具有下列副檔名的檔案)。在 Mac OS 與 Linux 上,AIR 可防止您開啟由特定應用程式啟動的檔案,這些特定應用程式如下所指定。嘗試使用 openWithDefaultApplication() 方法開啟這些檔案會產生例外。然而,以原生安裝程式 (擴充的桌面設定檔應用程式) 所安裝的 AIR 應用程式不會受限於這些限制;它們可以開啟任何類型的檔案。

您無法從應用程式目錄開啟文件。

下表列出在 Windows 上禁止的副檔名,以及在 Mac OS 及 Linux 上被禁止的應用程式:

Windows 文件副檔名 類型 Mac OS 應用程式對應 Linux 應用程式對應
bat 批次檔命令 終端機 無預設應用程式
cmd DOS 與 Windows 命令檔案 終端機 無預設應用程式
com 命令 終端機 無預設應用程式
csh UNIX csh 殼層指令碼 終端機 /bin/csh
dash UNIX dash 殼層指令碼 終端機 /bin/dash
ksh UNIX ksh 殼層指令碼 終端機 /bin/ksh
sh UNIX 殼層指令碼 終端機 /bin/bash
tcsh UNIX tcsh 殼層指令碼 終端機 /bin/tcsh
zsh UNIX zsh 殼層指令碼 終端機 /bin/zsh
exe 執行檔 可執行位元,.app 副檔名 /lib/ld.so
lnk Windows 捷徑檔 可執行位元,.app 副檔名 Linux 中的連結,已設定可執行位元,無預設應用程式
pif 程式資訊檔 可執行位元,.app 副檔名 不適用
reg Windows 登錄資料檔案的登錄資訊/機碼 不適用 不適用
scf Windows Explorer 命令 ScriptEditor,AutomatorRunner 不適用
shb、shs Shell Scrap 物件檔案 不適用 不適用
prg 程式檔 不適用 不適用
vb、vbe、vbs VBScript 檔案 不適用 不適用
vsmacros Visual Studio .NET 二進位巨集專案 不適用 不適用
ws、,wsc、wsf、wsh Windows 指令碼檔案 ScriptEditor,AutomatorRunner 不適用
fxp Fox Pro 已編譯的原始碼 不適用 不適用
mas Microsoft Access 預存程序 不適用 不適用
scr Windows 螢幕保護程式 不適用 不適用
py、pyc Python 指令碼檔案 Python Python
pl Perl 指令碼檔案 終端機 perl
cgi 通用閘道介面 (CGI) 指令碼檔案 終端機 perl
msi、msm、msp、mst、idt、cub、pcp Windows 安裝程式檔案 安裝程式 不適用
job Windows 工作排程器工作物件 不適用 不適用
jar、js、jse Java 封存檔案、JavaScript 檔案、JScript 編碼的指令碼檔案 JarLauncher jar
url 網際網路捷徑 不適用 不適用
hta HTML 應用程式 不適用 不適用

僅限 Mac OS X 類型 Mac OS X 應用程式 Linux 應用程式對應
不適用 Mac OS X Java applet AppletLauncher 不適用
不適用 Mac OS X AppleScript 外掛程式 systemevents 不適用
不適用 Mac OS X 介面工具集 停駐,dashboardlauncher 不適用

僅限 Linux 文件副檔名 類型 Mac OS X 應用程式對應 Linux 應用程式
rb Ruby 殼層指令碼 不適用 ruby
桌面 桌面檔案及捷徑 不適用 無預設應用程式
目錄 目錄檔案及捷徑 不適用 無預設應用程式


擲回值
Error — (Mac OS 與 Linux) 找不到可以開啟檔案的應用程式。(在 Windows 上,嘗試開啟的檔案沒有關聯的應用程式時,不會產生訊息和例外)。
 
IllegalOperationError — 檔案在應用程式目錄中,或者檔案是禁止的檔案類型。這個錯誤不適用於以原生應用程式安裝程式所安裝的 AIR 應用程式 (擴充的桌面描述檔應用程式)。
 
IOError — 檔案不存在,或沒有註冊用來開啟此檔案類型的應用程式。
 
ReferenceError — 檔案不存在。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼可讓使用者瀏覽至 MP3 檔案並在用於播放 MP3 檔案的預設應用程式中開啟。
import flash.filesystem.File;
import flash.net.FileFilter;

var file:File = File.documentsDirectory; 
var mp3Filter:FileFilter = new FileFilter("MP3 Files", "*.mp3"); 
file.browseForOpen("Open", [mp3Filter]); 
file.addEventListener(Event.SELECT, fileSelected); 
 
function fileSelected(e:Event):void 
{ 
    file.openWithDefaultApplication(); 
}

    requestPermission

()方法 
override public function requestPermission():void

語言版本: ActionScript 3.0
執行階段版本: AIR 24.0

要求權限以存取檔案系統。


事件
PermissionStatus:PermissionEvent — 由使用者授與/拒絕要求的權限時傳送。

    resolvePath

()方法 
public function resolvePath(path:String):File

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

根據 path 參數 (字串),使用此 File 物件路徑的相對路徑來建立新的 File 物件。

相對路徑或絕對路徑都可以做為 path 參數。

如果您指定相對路徑,指定的 path 會「附加」至 File 物件的路徑。不過,在 path 中使用 ".." 會傳回非 File 物件子系的結果路徑。產生的參考不需要參考實際的檔案系統位置。

如果您指定絕對檔案參考,此方法會傳回指向該路徑的 File 物件。絕對檔案參考應該使用使用者作業系統的有效原生路徑語法 (如 Windows 上的 "C:\\test")。請「勿」使用 URL (如 "file:///c:/test") 做為 path 參數。

所有產生的路徑都會一般化,如下所示:

  • 任何 "." 元素都會被忽略。
  • 任何 ".." 元素都會參考其父項目。
  • 到達檔案系統根目錄或應用程式持續儲存區根目錄的 ".." 參考不能通過該節點;它會被忽略。

請一律使用正斜線 (/) 字元做為路徑分隔符號。在 Windows 中,您也可以使用反斜線 (\) 字元,但不建議使用。使用反斜線字元會使應用程式在其他的平台上無法使用。

在 Linux 中,檔案名稱和目錄名稱一律會區分大小寫。

參數

path:String — 要附加至此 File 物件之路徑的路徑 (如果 path 參數是相對路徑) 或要傳回的路徑 (如果 path 參數是絕對路徑)。

傳回值
File — 指向結果路徑的新 File 物件。
事件詳細資訊
    

cancel

事件
事件物件類型: flash.events.Event
屬性 Event.type = flash.events.Event.CANCEL

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當待處理的非同步作業取消時傳送。

Event.CANCEL 常數會定義 cancel 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target在其上取消作業之物件的參照。
    

complete

事件  
事件物件類型: flash.events.Event
屬性 Event.type = flash.events.Event.COMPLETE

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當非同步作業完成時傳送。

Event.COMPLETE 常數會定義 complete 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target已完成載入的網路物件。
    

directoryListing

事件  
事件物件類型: flash.events.FileListEvent
屬性 FileListEvent.type = flash.events.FileListEvent.DIRECTORY_LISTING

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當目錄清單因為呼叫 getDirectoryListingAsync() 方法變成可供使用時傳送。

FileListEvent.DIRECTORY_LISTING 常數會定義 directoryListing 事件之事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
filesFile 物件的陣列,代表找到的檔案和目錄。
targetFileListEvent 物件。

相關 API 元素

    

ioError

事件  
事件物件類型: flash.events.IOErrorEvent
屬性 IOErrorEvent.type = flash.events.IOErrorEvent.IO_ERROR

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當非同步檔案作業期間發生錯誤時傳送。

定義 ioError 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
errorID與特定錯誤相關聯的參考號碼 (僅限 AIR)。
target遭遇輸入/輸出錯誤的網路物件。
text要顯示為錯誤訊息的文字。
    

permissionStatus

事件  
事件物件類型: flash.events.PermissionEvent
屬性 PermissionEvent.type = flash.events.PermissionEvent.PERMISSION_STATUS

語言版本: ActionScript 3.0
執行階段版本: AIR 24.0

當應用程式要求權限以存取檔案系統時傳送。檢查 status 屬性的值,以判斷是否已授與或拒絕權限

相關 API 元素

    

securityError

事件  
事件物件類型: flash.events.SecurityErrorEvent
屬性 SecurityErrorEvent.type = flash.events.SecurityErrorEvent.SECURITY_ERROR

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當作業違反安全性限制時傳送。

SecurityErrorEvent.SECURITY_ERROR 常數會定義 securityError 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target回報安全性錯誤的網路物件。
text要顯示為錯誤訊息的文字。
    

select

事件  
事件物件類型: flash.events.Event
屬性 Event.type = flash.events.Event.SELECT

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當使用者從檔案或目錄瀏覽對話方塊中選取檔案或目錄時傳送。

Event.SELECT 常數會定義 select 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target已經選取項目的物件。
    

selectMultiple

事件  
事件物件類型: flash.events.FileListEvent
屬性 FileListEvent.type = flash.events.FileListEvent.SELECT_MULTIPLE

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0

當使用者從呼叫 browseForOpenMultiple() 方法所開啟的對話方塊中選取檔案時傳送。

FileListEvent.SELECT_MULTIPLE 常數會定義 selectMultiple 事件之事件物件的 type 屬性值。
屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
filesFile 物件的陣列,代表選取的檔案。
targetFileListEvent 物件。

相關 API 元素





[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。