簡體   English   中英

在Windows Store應用程序中“打開”文件

[英]File “Open with” my Windows Store App

我希望Windows Store App可以通過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
}
  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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM