Windows Runtime (WinRT)

What is WinRT?

The Windows Runtime (WinRT) is a platform-agnostic application architecture introduced in Windows 8. It provides a set of APIs that enable developers to create modern, high‑performance applications that run across Windows devices, from desktops to tablets and phones.

Key Concepts

Getting Started

  1. Install the latest Visual Studio with the Desktop development with C++ and Universal Windows Platform development workloads.
  2. Create a new Blank App (Universal Windows) project.
  3. Explore the default MainPage.xaml and MainPage.xaml.cs files to see XAML UI and code‑behind.
  4. Run the project on the local machine or an emulator.

Sample Code

Read a text file asynchronously using the Windows.Storage APIs:

using Windows.Storage;
using System;

async void LoadFile()
{
    StorageFolder folder = ApplicationData.Current.LocalFolder;
    StorageFile file = await folder.GetFileAsync("sample.txt");
    string content = await FileIO.ReadTextAsync(file);
    System.Diagnostics.Debug.WriteLine(content);
}

Resources