Développer Réduire

StorageFile Class

Représente un fichier. Fournit des informations sur le fichier et son contenu, et la façon de les manipuler.

Syntaxe


/* Pour plus d’informations sur la création de cet objet et la façon d’y accéder, voir Remarques. */

Attributs

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

Membres

StorageFileClasse comporte les types de membres suivants :

Méthodes

The StorageFile Classe comporte les méthodes suivantes. Avec C#, Visual Basic et C++, il hérite également des méthodes de Object Classe.

MéthodeDescription
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.

 

Propriétés

StorageFileClasse contient les propriétés suivantes.

PropriétéType d’accèsDescription

Attributes

Lecture seuleGets the attributes of a file.

ContentType

Lecture seuleGets the MIME type of the contents of the file.

DateCreated

Lecture seuleGets the date and time when the current file was created.

DisplayName

Lecture seuleGets a user-friendly name for the file.

DisplayType

Lecture seuleGets a user-friendly description of the type of the file.

FileType

Lecture seuleGets the type (file name extension) of the file.

FolderRelativeId

Lecture seuleGets 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

Lecture seuleIndicates if the file is local, is cached locally, or can be downloaded.

Name

Lecture seuleGets the name of the file including the file name extension.

Path

Lecture seuleGets the full file-system path of the current file, if the file has a path.

Properties

Lecture seuleGets an object that provides access to the content-related properties of the file.

Provider

Lecture seuleGets the StorageProvider object that contains info about the service that stores the current file.

 

Remarques

En général, vous accédez aux objets StorageFile grâce à des appels de méthode asynchrone et/ou de fonction. Par exemple, les deux méthodes statiques GetFileFromPathAsync et GetFileFromApplicationUriAsync retournent un objet StorageFile qui représente le fichier spécifié.

En outre, chaque fois que vous appelez un sélecteur de fichier pour permettre à l'utilisateur de choisir un fichier (ou des fichiers), le sélecteur de fichier retourne le fichier sous la forme d'un StorageFile.

Remarque  Les objets StorageFile ne peuvent pas représenter des fichiers de type ".lnk", ".url" ou ".wsh".

Exemples

Cet exemple indique comment appeler un sélecteur de fichier, à l'aide de FileOpenPicker.PickSingleFileAsync pour capturer et traiter un fichier sélectionné par l'utilisateur.



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
   }
});

À la fin de l'exécution de PickSingleFileAsync, file obtient le fichier choisi comme StorageFile.

Dans l'exemple, openPicker contient un objet FileOpenPicker. Pour en savoir plus sur l'utilisation des sélecteurs de fichier, consultez FileOpenPicker et Démarrage rapide : accès aux fichiers à l'aide d'un sélecteur de fichiers.

En outre, fileToken obtient un identificateur que vous pouvez utiliser pour récupérer le fichier de FutureAccessList. Pour en savoir plus sur l'enregistrement des fichiers et des dossiers afin d'y accéder de nouveau ultérieurement, consultez FutureAccessList, MostRecentlyUsedList et Comment suivre les fichiers et les dossiers récemment utilisés.

Configuration requise

Client minimal pris en charge

Windows 8 [Applications du Windows Store uniquement]

Serveur minimal pris en charge

Windows Server 2012 [Applications du Windows Store uniquement]

Téléphone minimal pris en charge

Windows Phone 8

Espace de noms

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

Métadonnées

Windows.winmd

Capabilities

picturesLibrary
videosLibrary
musicLibrary
documentsLibrary

Voir aussi

StorageFolder
IStorageFile
IStorageItem
IRandomAccessStreamReference
IInputStreamReference
IStorageItemProperties
IStorageItemProperties2
IStorageItem2
IStorageItemPropertiesWithProvider
IStorageFilePropertiesWithAvailability

 

 

Afficher:
© 2014 Microsoft