Archives
-
File Activation in Windows RT
The code sample for file activation on MSDN is lacking some code so a simple way to pass the file clicked to your MainPage could be:
protected override void OnFileActivated(FileActivatedEventArgs args)
{
var page = new Frame();
page.Navigate(typeof(MainPage));
Window.Current.Content = page;
var p = page.Content as MainPage;
if (p != null) p.FileEvent = args;
Window.Current.Activate();
}
And in MainPage:
public MainPage()
{
InitializeComponent();
Loaded += MainPageLoaded;
}
void MainPageLoaded(object sender, RoutedEventArgs e)
{
if (FileEvent != null && FileEvent.Files.Count > 0)
{
//… do something with file
}
}
-
Read All Text from Textfile with Encoding in Windows RT
A simple extension for reading all text from a text file in WinRT with a specific encoding, made as an extension to StorageFile:
public static class StorageFileExtensions
{
async public static Task<string> ReadAllTextAsync(this StorageFile storageFile)
{
var buffer = await FileIO.ReadBufferAsync(storageFile);
var fileData = buffer.ToArray();
var encoding = Encoding.GetEncoding("Windows-1252");
var text = encoding.GetString(fileData, 0, fileData.Length);
return text;
}
} -
Sideloading and Testing Windows 8 Store Apps on Other Machines
This is a good, short article how to create a store app package and test on another machine, see http://blog.aggregatedintelligence.com/2012/11/how-to-sideload-windows-8-store-apps.html