Clase StorageFile
TOC
Collapse the table of content
Expand the table of content

StorageFile Class

Representa un archivo. Proporciona información sobre el archivo y su contenido, y la forma de manipularlos.

Sintaxis


/* Para obtener información sobre cómo crear o tener acceso a este objeto, consulte Notas. */

Atributos

[Muse()]
[Version(0x06020000)]

Miembros

StorageFileClase tiene estos tipos de miembros:

Métodos

The StorageFile Clase tiene estos métodos. Con C#, Visual Basic y C++, también hereda métodos de Object Clase.

MétodoDescripción
CopyAndReplaceAsync Replaces the specified file with a copy of the current file.
CopyAsync(IStorageFolder) Creates a copy of the file in the specified folder.
CopyAsync(IStorageFolder, String) Creates a copy of the file in the specified folder, using the desired name.
CopyAsync(IStorageFolder, String, NameCollisionOption) Creates a copy of the file in the specified folder, using the desired name. This method also specifies what to do if an existing file in the specified folder has the same name.
CreateStreamedFileAsync Creates a StorageFile to represent the specified stream of data. This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream is first accessed.
CreateStreamedFileFromUriAsync Creates a StorageFile to represent a stream of data from the specified Uniform Resource Identifier (URI) resource. This method lets the app download the data on-demand when the StorageFile that represents the stream is first accessed.
DeleteAsync() Deletes the current file.
DeleteAsync(StorageDeleteOption) Deletes the current file, optionally deleting the item permanently.
GetBasicPropertiesAsync Gets the basic properties of the current file.
GetFileFromApplicationUriAsync Gets a StorageFile object to represent the specified Uniform Resource Identifier (URI) app resource.
GetFileFromPathAsync Gets a StorageFile object to represent the file at the specified path.
GetParentAsync Gets the parent folder of the current file.
GetScaledImageAsThumbnailAsync(ThumbnailMode) Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail.
GetScaledImageAsThumbnailAsync(ThumbnailMode, UInt32) Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail and the requested size.
GetScaledImageAsThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions) Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail, the requested size, and the specified options
GetThumbnailAsync(ThumbnailMode) Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail.
GetThumbnailAsync(ThumbnailMode, UInt32) Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail and the requested size.
GetThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions) Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail, the requested size, and the specified options.
IsEqual Indicates whether the current file is equal to the specified file.
IsOfType Determines whether the current StorageFile matches the specified StorageItemTypes value.
MoveAndReplaceAsync Moves the current file to the location of the specified file and replaces the specified file in that location.
MoveAsync(IStorageFolder) Moves the current file to the specified folder.
MoveAsync(IStorageFolder, String) Moves the current file to the specified folder and renames the file according to the desired name.
MoveAsync(IStorageFolder, String, NameCollisionOption) Moves the current file to the specified folder and renames the file according to the desired name. This method also specifies what to do if a file with the same name already exists in the specified folder.
OpenAsync Opens a random-access stream over the file.
OpenReadAsync Opens a random-access stream over the current file for reading file contents.
OpenSequentialReadAsync Opens a sequential-access stream over the current file for reading file contents.
OpenTransactedWriteAsync Opens a random-access stream to the file that can be used for transacted-write operations.
RenameAsync(String) Renames the current file.
RenameAsync(String, NameCollisionOption) Renames the current file. This method also specifies what to do if an existing item in the current file's location has the same name.
ReplaceWithStreamedFileAsync Replaces the contents of the file referred to by the specified IStorageFile object with a new data stream. This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream is first accessed.
ReplaceWithStreamedFileFromUriAsync Replaces the contents of the file referred to by the specified IStorageFile object with a new data stream of the specified Uniform Resource Identifier (URI). This method lets the app download the data on-demand when the StorageFile that represents the stream is first accessed.

 

Propiedades

StorageFileClase tiene estas propiedades.

PropiedadTipo de accesoDescripción

Attributes

Solo lecturaGets the attributes of a file.

ContentType

Solo lecturaGets the MIME type of the contents of the file.

DateCreated

Solo lecturaGets the date and time when the current file was created.

DisplayName

Solo lecturaGets a user-friendly name for the file.

DisplayType

Solo lecturaGets a user-friendly description of the type of the file.

FileType

Solo lecturaGets the type (file name extension) of the file.

FolderRelativeId

Solo lecturaGets an identifier for the file. This ID is unique for the query result or StorageFolder that contains the file and can be used to distinguish between items that have the same name.

IsAvailable

Solo lecturaIndicates if the file is local, is cached locally, or can be downloaded.

Name

Solo lecturaGets the name of the file including the file name extension.

Path

Solo lecturaGets the full file-system path of the current file, if the file has a path.

Properties

Solo lecturaGets an object that provides access to the content-related properties of the file.

Provider

Solo lecturaGets the StorageProvider object that contains info about the service that stores the current file.

 

Observaciones

Normalmente, se tiene acceso a los objetos StorageFile como resultado del método asincrónico o de llamadas de función. Por ejemplo, los dos métodos estáticos GetFileFromPathAsync y GetFileFromApplicationUriAsync devuelven un objeto StorageFile que representa el archivo especificado.

Además, siempre que se llama a un selector de archivos para permitir al usuario elegir un archivo (o varios archivos) el selector de archivos devolverá el archivo como StorageFile.

Nota  Los objetos StorageFile no pueden representar archivos de tipo ".lnk", ".url" o ".wsh".

Ejemplos

En este ejemplo se muestra cómo llamar a un selector de archivos mediante FileOpenPicker.PickSingleFileAsync para capturar y procesar un archivo que el usuario escoge.



openPicker.pickSingleFileAsync().then(function (file) {
   if (file) {
       // Process picked file

       // Store file for future access
       var fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList.add(file);
   } else {
       // The user didn't pick a file
   }
});

Después de que PickSingleFileAsync se complete, file obtiene el archivo seleccionado como StorageFile.

En el ejemplo, openPicker contiene un objeto FileOpenPicker. Para obtener más información sobre cómo usar los selectores de archivos, vea FileOpenPicker eInicio rápido: obtener acceso a archivos con selectores de archivos.

Además, fileToken obtiene un identificador que puede utilizar para recuperar el archivo de FutureAccessList. Para obtener más información sobre el almacenamiento de archivos y carpetas para que se pueda tener acceso a ellos más tarde, vea FutureAccessList, MostRecentlyUsedList y Cómo hacer un seguimiento de los archivos y carpetas usados recientemente.

Requisitos

Cliente mínimo compatible

Windows 8 [Solo aplicaciones de la Tienda Windows]

Servidor mínimo compatible

Windows Server 2012 [Solo aplicaciones de la Tienda Windows]

Teléfono mínimo compatible

Windows Phone 8

Espacio de nombres

Windows.Storage
Windows::Storage [C++]

Metadatos

Windows.winmd

Capabilities

picturesLibrary
videosLibrary
musicLibrary
documentsLibrary

Consulta también

StorageFolder
IStorageFile
IStorageItem
IRandomAccessStreamReference
IInputStreamReference
IStorageItemProperties
IStorageItemProperties2
IStorageItem2
IStorageItemPropertiesWithProvider
IStorageFilePropertiesWithAvailability

 

 

Mostrar:
© 2017 Microsoft