UWP C# 在记事本中打开文本文件

Roy Li - MSFT 32,486 信誉分 Microsoft 供应商
2024-05-08T09:10:08.5933333+00:00

UWP 应用是否可以在记事本中打开文本文件(打开记事本)?

谢谢

此问题由UWP C# Opening a text file in Notepad. - Microsoft Q&A总结而来.

通用 Windows 平台 (UWP)
通用 Windows 平台 (UWP)
一个 Microsoft 平台,用于生成和发布适用于 Windows 桌面设备的应用。
29 个问题
0 个注释 无注释
{count} 票

1 个答案

排序依据: 非常有帮助
  1. Junjie Zhu - MSFT 15,756 信誉分 Microsoft 供应商
    2024-05-08T09:59:31.5866667+00:00

    你好

    您可以参考文档启动文件的默认应用程序,选择文件打开方法,选择记事本打开txt文件。

    async void DefaultLaunch()  
    {  
       // Path to the file in the app package to launch  
          string imageFile = @"images\test.png";  
            
       var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);  
      
       if (file != null)  
       {  
          // Set the option to show the picker  
          var options = new Windows.System.LauncherOptions();  
          options.DisplayApplicationPicker = true;  
      
          // Launch the retrieved file  
          bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);  
          if (success)  
          {  
             // File launched  
          }  
          else  
          {  
             // File launch failed  
          }  
       }  
       else  
       {  
          // Could not find file  
       }  
    }
    

    谢谢。


    如果答案是正确的,请点击“接受答案”并点赞。 如果您对此答案还有其他疑问,请点击“评论”。 注意:如果您想接收电子邮件通知,请按照我们的文档中的步骤启用电子邮件通知 此线程的相关电子邮件通知。

    0 个注释 无注释