Table of Contents

Class StorageFolder

Namespace
Windows.Storage
Assembly
Windows.Storage.dll

Manages folders and their contents and provides information about them.

public sealed class StorageFolder : IStorageFolder, IStorageItem
Inheritance
StorageFolder
Implements
Inherited Members
Extension Methods

Properties

Attributes

Gets the attributes of the current folder.

public FileAttributes Attributes { get; }

Property Value

FileAttributes

The attributes of the current folder.

DateCreated

Gets the date and time that the current folder was created.

public DateTime DateCreated { get; }

Property Value

DateTime

Remarks

This is the nanoFrameowrk equivalent of UWP DateCreated of type DateTimeOffset.

DisplayName

Gets the user-friendly name of the current folder.

public string DisplayName { get; }

Property Value

string

Remarks

This property is not available in nanoFramework.

DisplayType

Gets the user-friendly description of the type of the folder.

public string DisplayType { get; }

Property Value

string

Remarks

This property is not available in nanoFramework.

FolderRelativeId

Gets an identifier for the current folder. This ID is unique for the query result or StorageFolder that contains the current folder or file group, and can be used to distinguish between items that have the same name.

public string FolderRelativeId { get; }

Property Value

string

Remarks

This property is not available in nanoFramework.

Name

Gets the name of the current folder.

public string Name { get; }

Property Value

string

The name of the current folder.

Path

Gets the full path of the current folder in the file system, if the path is available.

public string Path { get; }

Property Value

string

Methods

CreateFile(string)

Creates a new file with the specified name in the current folder.

public StorageFile CreateFile(string desiredName)

Parameters

desiredName string

The name of the new file to create in the current folder.

Returns

StorageFile

When this method completes, it returns a StorageFile that represents the new file.

Remarks

This method uses the FailIfExists value from the CreationCollisionOption enumeration by default. That is, this method raises an exception if a subfolder with the same name already exists in the current folder. If you want to handle a folder name collision in a different way, call the CreateFile(string, CreationCollisionOption) method.

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be CreateFileAsync(String).

CreateFile(string, CreationCollisionOption)

Creates a new file with the specified name in the current folder.

public StorageFile CreateFile(string desiredName, CreationCollisionOption options)

Parameters

desiredName string

The name of the new file to create in the current folder.

options CreationCollisionOption

One of the enumeration values that determines how to handle the collision if a file with the specified desiredName already exists in the current folder.

Returns

StorageFile

When this method completes, it returns a StorageFile that represents the new file.

Remarks

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be CreateFileAsync(String, CreationCollisionOption).

CreateFolder(string)

Creates a new subfolder with the specified name in the current folder.

public StorageFolder CreateFolder(string desiredName)

Parameters

desiredName string

The name of the new subfolder to create in the current folder.

Returns

StorageFolder

When this method completes, it returns a StorageFolder that represents the new subfolder.

Remarks

This method uses the FailIfExists value from the CreationCollisionOption enumeration by default. That is, this method raises an exception if a subfolder with the same name already exists in the current folder. If you want to handle a folder name collision in a different way, call the CreateFolder(string, CreationCollisionOption) method.

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be CreateFolderAsync(String).

CreateFolder(string, CreationCollisionOption)

Creates a new subfolder with the specified name in the current folder. This method also specifies what to do if a subfolder with the same name already exists in the current folder.

public StorageFolder CreateFolder(string desiredName, CreationCollisionOption options)

Parameters

desiredName string

The name of the new subfolder to create in the current folder.

options CreationCollisionOption

One of the enumeration values that determines how to handle the collision if a subfolder with the specified desiredName already exists in the current folder.

Returns

StorageFolder

When this method completes, it returns a StorageFolder that represents the new subfolder.

Remarks

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be CreateFolderAsync(String, CreationCollisionOption).

Delete()

Delete the current folder.

public void Delete()

Remarks

If the folder doesn't exist then this method will throw an exception.

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be DeleteAsync().

GetFiles()

Gets the files in the current folder.

public StorageFile[] GetFiles()

Returns

StorageFile[]

When this method completes successfully, it returns a list of the files in the current folder. The list is of type StorageFile. Each file in the list is represented by a StorageFile object.

Remarks

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be GetFilesAsync().

GetFiles(CommonFileQuery)

Gets the files in the current folder. Also gets the files from the subfolders of the current folder when the value of the query argument is something other than DefaultQuery. Files are sorted based on the specified value from the CommonFileQuery enumeration.

public StorageFile[] GetFiles(CommonFileQuery query)

Parameters

query CommonFileQuery

One of the enumeration values that specifies how to sort the files and determines whether the query is shallow or deep.

Returns

StorageFile[]

When this method completes successfully, it returns a flat list of files, sorted as specified by query. The list is of type StorageFile. Each file in the list is represented by a StorageFile object.

Remarks

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be GetFilesAsync(CommonFileQuery).

GetFiles(CommonFileQuery, uint, uint)

Gets an index-based range of files from the list of all files in the current folder. Also gets the files from the subfolders of the current folder when the value of the query argument is something other than DefaultQuery. Files are sorted based on the specified value from the CommonFileQuery enumeration.

public StorageFile[] GetFiles(CommonFileQuery query, uint startIndex, uint maxItemsToRetrieve)

Parameters

query CommonFileQuery

One of the enumeration values that specifies how to sort the files and determines whether the query is shallow or deep.

startIndex uint

The zero-based index of the first file in the range to retrieve.

maxItemsToRetrieve uint

The maximum number of files to retrieve.

Returns

StorageFile[]

When this method completes successfully, it returns a flat list of files, sorted as specified by query. The list is of type StorageFile. Each file in the list is represented by a StorageFile object.

Remarks

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be GetFilesAsync(CommonFileQuery, UInt32, UInt32).

GetFolder(string)

Gets the subfolder with the specified name from the current folder.

public StorageFolder GetFolder(string name)

Parameters

name string

The name (or path relative to the current folder) of the subfolder to get.

Returns

StorageFolder

When this method completes successfully, it returns a StorageFolder that represents the specified subfolder.

Remarks

If the folder doesn't exist it will throw an exception.

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be GetFolderAsync(String name).

GetFolders()

Gets the subfolders in the current folder.

public StorageFolder[] GetFolders()

Returns

StorageFolder[]

When this method completes successfully, it returns a list of the subfolders in the current folder. The list is of type StorageFolder. Each folder in the list is represented by a StorageFolder object.

Remarks

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be GetFoldersAsync().

IsCommonFileQuerySupported(CommonFileQuery)

Indicates whether the current folder supports the specified CommonFileQuery.

public bool IsCommonFileQuerySupported(CommonFileQuery query)

Parameters

query CommonFileQuery

The value to test.

Returns

bool

True if the folder supports the specified CommonFileQuery otherwise, false.

Rename(string)

Renames the current folder.

public void Rename(string desiredName)

Parameters

desiredName string

The desired, new name for the current folder.

Remarks

If the name you specify is invalid or a folder with the same name already exists, this method throws an exception. If the target device doesn't support folders then this will also throw an exception.

This method is exclusive of nanoFramework and it's not available in the UWP API. The equivalent method would be RenameAsync(String desiredName).