0

我希望Windows Store App通过 Windows 资源管理器的“右键单击/打开方式”命令来处理打开 txt 文件。

我的应用程序完美地显示在可用应用程序列表中,我可以点击它,但我不知道应该注册哪个事件才能获取文件名和内容。

任何的想法?

4

2 回答 2

1

请参阅 MSDN 上的这篇文章如何处理文件激活

您需要处理 OnFileActivated 事件

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
}
于 2013-02-15T10:21:28.537 回答
0
  1. 在解决方案资源管理器中打开 package.appxmanifest。
  2. 选择声明选项卡。
  3. 从下拉列表中选择文件类型关联,然后单击添加。
  4. 输入 txt 作为名称。
  5. 输入 .txt 作为文件类型。
  6. 输入“images\Icon.png”作为徽标。

在应用程序包中添加正确的图标

在 c# 中,您需要处理 OnFileActivated 事件

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
}
于 2014-07-07T07:12:07.067 回答