Tim Bee
Tim Bee

Reputation: 2230

File "Open with" my Windows Store App

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?

Upvotes: 0

Views: 812

Answers (2)

shedskin
shedskin

Reputation: 45

  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
}

Upvotes: 0

Haris Hasan
Haris Hasan

Reputation: 30097

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
}

Upvotes: 1

Related Questions