文件“打开”我的Windows应用商店

时间:2013-02-15 10:16:06

标签: c# windows-runtime windows-store-apps

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

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

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

在MSDN How to handle file activation

上查看此文章

您需要处理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
}

答案 1 :(得分:0)

  1. 在解决方案资源管理器中打开package.appxmanifest。
  2. 选择声明选项卡。
  3. 从下拉列表中选择文件类型关联,然后单击添加。
  4. 输入txt作为名称。
  5. 输入.txt作为文件类型。
  6. 输入“images \ Icon.png”作为徽标。
  7. 在应用包中添加适当的图标

    并且在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
    }