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 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 FileAttributespublic FileAttributes Attributes { get; }

    Property Value

  • DateCreated
    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 DateTimeOffsetpublic DateTime DateCreated { get; }

    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 stringpublic string Name { get; }

    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 stringpublic string Path { get; }

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

    Returns

    Remarks

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

  • DeleteAsync(StorageDeleteOption)
    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 IAsyncActionpublic IAsyncAction DeleteAsync(StorageDeleteOption option)

    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 )public IAsyncOperation<BasicProperties> GetBasicPropertiesAsync()

    Returns

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

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

    Determines whether the current IStorageItem matches the specified StorageItemTypes value.

    public bool IsOfType(StorageItemTypes type)public bool IsOfType(StorageItemTypes type)Public Function IsOfType(type As StorageItemTypes) As boolpublic bool IsOfType(StorageItemTypes type)

    Parameters

    Returns

    • bool
      bool
      bool
      bool

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

  • RenameAsync(String)
    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 IAsyncActionpublic IAsyncAction RenameAsync(String desiredName)

    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(String, NameCollisionOption)
    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 IAsyncActionpublic IAsyncAction RenameAsync(String desiredName, NameCollisionOption option)

    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.ContractVersionAttribute
Windows.Foundation.Metadata.GuidAttribute

Details

Assembly

Windows.Storage.dll