Export (0) Print
Expand All

WindowsRuntimeStorageExtensions Class

.NET Framework 4.5

Contains extension methods for the IStorageFile and IStorageFolder interfaces in the Windows Runtime when developing Windows Store apps.

System::Object
  System.IO::WindowsRuntimeStorageExtensions

Namespace:  System.IO
Assembly:  System.Runtime.WindowsRuntime (in System.Runtime.WindowsRuntime.dll)

[ExtensionAttribute]
public ref class WindowsRuntimeStorageExtensions abstract sealed

  NameDescription
Public methodStatic memberSupported in .NET for Windows Store appsOpenStreamForReadAsync(IStorageFile)Retrieves a stream for reading from a specified file.
Public methodStatic memberSupported in .NET for Windows Store appsOpenStreamForReadAsync(IStorageFolder, String)Retrieves a stream for reading from a file in the specified parent folder.
Public methodStatic memberSupported in .NET for Windows Store appsOpenStreamForWriteAsync(IStorageFile)Retrieves a stream for writing to a specified file.
Public methodStatic memberSupported in .NET for Windows Store appsOpenStreamForWriteAsync(IStorageFolder, String, CreationCollisionOption)Retrieves a stream for writing to a file in the specified parent folder.
Top

These extension methods are available only when you develop Windows Store apps. The methods provide convenient ways of opening files for reading or writing in Windows Store apps. You do not create an instance of the WindowsRuntimeStorageExtensions class; instead, you use these methods from instances of the IStorageFile and IStorageFolder interfaces.

The WindowsRuntimeStorageExtensions class contains two methods that extend IStorageFile for reading or writing:

The WindowsRuntimeStorageExtensions class contains two methods that extend IStorageFolder for reading and writing:

The following example shows how to open a file in the application data as a Stream in a Windows Store app, and write to it by using an instance of the StreamWriter class. It then reads the contents for the file by using an instance of the StreamReader class.

No code example is currently available or this language may not be supported.

The next example shows the XAML code that is associated with the previous example.

<Page
    x:Class="ExampleApplication.BlankPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ExampleApplication"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Background="{StaticResource ApplicationPageBackgroundBrush}" VerticalAlignment="Center" HorizontalAlignment="Center">
        <TextBlock Text="Provide text to write to file:"></TextBlock>
        <TextBox Name="UserText" Width="400"></TextBox>
        <Button Name="CreateButton" Content="Create File" Click="CreateButton_Click"></Button>
        <Button Name="VerifyButton" Content="Verify Contents" Click="VerifyButton_Click"></Button>
        <TextBlock Name="Results"></TextBlock>
    </StackPanel>
</Page>

.NET Framework

Supported in: 4.5.3

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone Silverlight 8

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft