Reputation: 241
Coming from a Windows Forms background, I am used to being able to handle arguments, in the Program.cs file, passed to my application, when a user tries to open a Text file from Windows Explorer, so that my application can display its contents to the user.
However, in Metro style Apps, we don't have the Program.cs file anymore. We have the App.xaml or App.xaml.cs file.
Seeing as though I cannot find relevant documentation on this, I could just try doing it "the usual" way, in the App.xaml.cs file but I'm not even sure if that's the right way to go about it. I have Added the appropriate Capabilities and File type Associations to my Metro style App, but other than that I am don't know where to start.
How can we open a supported file from the Documents folder into our own Metro style Apps?
Upvotes: 1
Views: 1623
Reputation: 45
add the proper icons in the app package
and in c#, You need to handle OnFileActivated event
protected override void OnFileActivated(FileActivatedEventArgs args)
{
// TODO: Handle file activation
// The number of files received is args.Files.Size
// The first file is args.Files[0].Name
}
Upvotes: 0
Reputation: 7292
You handle this by two specific steps:
Full details are here. Once you've got the files, you can use the standard Windows.Storage API's to access those files.
Upvotes: 0
Reputation: 5633
See How to handle file activation @ http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh779669.aspx
Upvotes: 1