I​Storage​Item I​Storage​Item I​Storage​Item Interface

Definition

Manipulates storage items (files and folders) and their contents, and provides information about them.

Important

If you simply want to work with files and folders in your app, see the StorageFile and StorageFolder classes.

public interface IStorageItempublic interface IStorageItemPublic Interface IStorageItem
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Properties

Attributes Attributes Attributes

Gets the attributes of a storage item.

public FileAttributes Attributes { get; }public FileAttributes Attributes { get; }Public ReadOnly Property Attributes As FileAttributes
Value
FileAttributes FileAttributes FileAttributes

The file or folder attributes.

Attributes

DateCreated DateCreated DateCreated

Gets the date and time when the current item was created.

public DateTime DateCreated { get; }public DateTimeOffset DateCreated { get; }Public ReadOnly Property DateCreated As DateTimeOffset
Value
DateTime DateTime DateTime

The date and time when the current item was created.

For example, in string format the DateTime that an item was created might be "Fri Sep 16 13:47:08 PDT 2011".

Attributes

Remarks

If the date property isn't set, this value defaults to 0 which can be translated into misleading dates in different programming languages. In JavaScript, for example, 0 translates to December 16, 1600. You should always check that this property is a real value and not 0.

Name Name Name

Gets the name of the item including the file name extension if there is one.

public PlatForm::String Name { get; }public string Name { get; }Public ReadOnly Property Name As string
Value
string string string

The name of the item including the file name extension if there is one.

Attributes

Remarks

If the item is a file, this name includes the file name extension.

Path Path Path

Gets the full file-system path of the item, if the item has a path.

public PlatForm::String Path { get; }public string Path { get; }Public ReadOnly Property Path As string
Value
string string string

The full path of the item, if the item has a path in the user's file-system.

Attributes

Remarks

Do not rely on this property to access an item because some items may not have file-system paths. For example if the item is backed by a URI, or was picked using the file picker, the item is not guaranteed to have a file-system path.

Methods

DeleteAsync() DeleteAsync() DeleteAsync()

Deletes the current item.

public IAsyncAction DeleteAsync()public IAsyncAction DeleteAsync()Public Function DeleteAsync() As IAsyncAction
Returns

No object or value is returned by this method when it completes.

Attributes

Remarks

This method uses StorageDeleteOption.default to determine whether the item is deleted permanently.

DeleteAsync(StorageDeleteOption) DeleteAsync(StorageDeleteOption) DeleteAsync(StorageDeleteOption)

Deletes the current item, optionally deleting it permanently.

public IAsyncAction DeleteAsync(StorageDeleteOption option)public IAsyncAction DeleteAsync(StorageDeleteOption option)Public Function DeleteAsync(option As StorageDeleteOption) As IAsyncAction
Parameters
option
StorageDeleteOption StorageDeleteOption StorageDeleteOption

A value that indicates whether to delete the item permanently.

Returns

No object or value is returned by this method when it completes.

Attributes

GetBasicPropertiesAsync() GetBasicPropertiesAsync() GetBasicPropertiesAsync()

Gets the basic properties of the current item (like a file or folder).

public IAsyncOperation<BasicProperties> GetBasicPropertiesAsync()public IAsyncOperation<BasicProperties> GetBasicPropertiesAsync()Public Function GetBasicPropertiesAsync() As IAsyncOperation( Of BasicProperties )
Returns

When this method completes successfully, it returns the basic properties of the current item as a BasicProperties object.

Attributes

IsOfType(StorageItemTypes) IsOfType(StorageItemTypes) IsOfType(StorageItemTypes)

Determines whether the current IStorageItem matches the specified StorageItemTypes value.

public PlatForm::Boolean IsOfType(StorageItemTypes type)public bool IsOfType(StorageItemTypes type)Public Function IsOfType(type As StorageItemTypes) As bool
Parameters
type
StorageItemTypes StorageItemTypes StorageItemTypes

The value to match against.

Returns
bool bool bool

True if the IStorageItem matches the specified value; otherwise false.

Attributes

RenameAsync(String) RenameAsync(String) RenameAsync(String)

Renames the current item.

public IAsyncAction RenameAsync(String desiredName)public IAsyncAction RenameAsync(String desiredName)Public Function RenameAsync(desiredName As String) As IAsyncAction
Parameters
desiredName
System.String System.String System.String

The desired, new name of the item.

Returns

No object or value is returned by this method when it completes.

Attributes

Remarks

For this method and its overload, if the name you specify is invalid, this method throws an exception. To handle all the ways the specified name could be invalid, you must catch all four of these exceptions:

E_INVALIDARG
E_FAIL
ERROR_FILENAME_EXCED_RANGE
ERROR_INVALID_NAME

If the file is deleted before the rename finishes, this method throws the ERROR_FILE_NOT_FOUND exception. You must also catch and handle this exception when you use this method.

RenameAsync(String, NameCollisionOption) RenameAsync(String, NameCollisionOption) RenameAsync(String, NameCollisionOption)

Renames the current item. This method also specifies what to do if an existing item in the current item's location has the same name.

public IAsyncAction RenameAsync(String desiredName, NameCollisionOption option)public IAsyncAction RenameAsync(String desiredName, NameCollisionOption option)Public Function RenameAsync(desiredName As String, option As NameCollisionOption) As IAsyncAction
Parameters
desiredName
System.String System.String System.String

The desired, new name of the current item.

If there is an existing item in the current item's location that already has the specified desiredName, the specified NameCollisionOption determines how Windows responds to the conflict.

option
NameCollisionOption NameCollisionOption NameCollisionOption

The enum value that determines how Windows responds if the desiredName is the same as the name of an existing item in the current item's location.

Returns

No object or value is returned by this method when it completes.

Attributes