0

I'd like my Windows Store App to handle opening txt files via the "Right-Click/Open With" command of the Windows Explorer.

My app perfectly shows up in the list of available applications to use and I can click on it, but I have no idea which event I should register to in order to grab the file name & content.

Any idea?

Timothée Bourguignon
  • 2,190
  • 3
  • 23
  • 39

2 Answers2

1

See this article on MSDN How to handle file activation

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
}
Haris Hasan
  • 29,856
  • 10
  • 92
  • 122
  • Damn, that's what it's called `File Activation`! When you have the right keywords its a lot easier to find ;) Thanks a lot! – Timothée Bourguignon Feb 15 '13 at 10:30
  • I tried to edit your answer but the edition was somehow rejected: `Files.Size` does not exist, the MSDN code extract is wrong, it is `Files.Count`. And `Files[0].Name` does not represent the `first file` but the `name of the first file`. – Timothée Bourguignon Feb 15 '13 at 11:28
0
  1. open package.appxmanifest in Solution Explorer.
  2. Select the Declarations tab.
  3. Select File Type Associations from the drop-down list and click Add.
  4. Enter txt as the Name.
  5. Enter .txt as the File Type.
  6. Enter “images\Icon.png” as the Logo.

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
}
shedskin
  • 45
  • 9