Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 文件“用”我的Windows应用商店应用打开_C#_Windows Runtime_Windows Store Apps - Fatal编程技术网

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

C# 文件“用”我的Windows应用商店应用打开,c#,windows-runtime,windows-store-apps,C#,Windows Runtime,Windows Store Apps,我希望我的Windows应用商店应用程序能够通过Windows资源管理器的右键单击/打开命令来打开txt文件 我的应用程序完美地显示在可用应用程序列表中,我可以单击它,但我不知道应该注册哪个事件才能获取文件名和内容 有什么想法吗?请参阅MSDN上的这篇文章 您需要处理OnFileActivated事件 protected override void OnFileActivated(FileActivatedEventArgs args) { // TODO: Handle file

我希望我的Windows应用商店应用程序能够通过Windows资源管理器的右键单击/打开命令来打开txt文件

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

有什么想法吗?

请参阅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
}
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
}
在解决方案资源管理器中打开package.appxmanifest。 选择“声明”选项卡。 从下拉列表中选择文件类型关联,然后单击添加。 输入txt作为名称。 输入.txt作为文件类型。 输入“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
}
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
}

该死,这就是所谓的文件激活!当你有了正确的关键字,它会更容易找到;谢谢!我试图编辑您的答案,但版本被拒绝:Files.Size不存在,MSDN代码提取错误,是Files.Count。和文件[0]。名称不代表第一个文件,而是第一个文件的名称。