IStorageItem IStorageItem IStorageItem IStorageItem Interface

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.

Syntax

Declaration

public interface IStorageItempublic interface IStorageItemPublic Interface IStorageItem

Properties summary

Gets the attributes of a storage item.

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

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

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

Methods summary

Deletes the current item.

Deletes the current item, optionally deleting it permanently.

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

Determines whether the current IStorageItem matches the specified StorageItemTypes value.

Renames the current item.

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.

Properties

  • Attributes
    Attributes
    Attributes
    Attributes

    Gets the attributes of a storage item.

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

    Property Value

  • DateCreated
    DateCreated
    DateCreated
    DateCreated

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

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

    Property Value

    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
    Name

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

    public string Name { get; }public string Name { get; }Public ReadOnly Property Name As string

    Property Value

    • string
      string
      string
      string

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

    Remarks

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

  • Path
    Path
    Path
    Path

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

    public string Path { get; }public string Path { get; }Public ReadOnly Property Path As string

    Property Value

    • string
      string
      string
      string

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

    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()
    DeleteAsync()

    Deletes the current item.

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

    Returns

    Remarks

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

  • DeleteAsync(Windows.Storage.StorageDeleteOption)
    DeleteAsync(Windows.Storage.StorageDeleteOption)
    DeleteAsync(Windows.Storage.StorageDeleteOption)
    DeleteAsync(Windows.Storage.StorageDeleteOption)

    Deletes the current item, optionally deleting it permanently.

    public IAsyncAction DeleteAsync(Windows.Storage.StorageDeleteOption)public IAsyncAction DeleteAsync(Windows.Storage.StorageDeleteOption)Public Function DeleteAsync(Windows.Storage.StorageDeleteOption) As IAsyncAction

    Parameters

    Returns

  • GetBasicPropertiesAsync()
    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.

  • IsOfType(Windows.Storage.StorageItemTypes)
    IsOfType(Windows.Storage.StorageItemTypes)
    IsOfType(Windows.Storage.StorageItemTypes)
    IsOfType(Windows.Storage.StorageItemTypes)

    Determines whether the current IStorageItem matches the specified StorageItemTypes value.

    public bool IsOfType(Windows.Storage.StorageItemTypes)public bool IsOfType(Windows.Storage.StorageItemTypes)Public Function IsOfType(Windows.Storage.StorageItemTypes) As bool

    Parameters

    Returns

    • bool
      bool
      bool
      bool

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

  • RenameAsync(System.String)
    RenameAsync(System.String)
    RenameAsync(System.String)
    RenameAsync(System.String)

    Renames the current item.

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

    Parameters

    • desiredName
      System.String
      System.String
      System.String
      System.String

      The desired, new name of the item.

    Returns

    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(System.String,Windows.Storage.NameCollisionOption)
    RenameAsync(System.String,Windows.Storage.NameCollisionOption)
    RenameAsync(System.String,Windows.Storage.NameCollisionOption)
    RenameAsync(System.String,Windows.Storage.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(System.String,Windows.Storage.NameCollisionOption)public IAsyncAction RenameAsync(System.String,Windows.Storage.NameCollisionOption)Public Function RenameAsync(System.String,Windows.Storage.NameCollisionOption) As IAsyncAction

    Parameters

    • desiredName
      System.String
      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

      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

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.GuidAttribute
Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Storage.dll