StreamReader 代码在将其转换为 DesktopBridge APP 后引发异常

StreamReader code raises exception after converting it to DesktopBridge APP

我有这个使用以下代码的小型 WPF 应用程序。基本上它读取所述文件以显示内容。

using (StreamReader streamReader = new StreamReader(@"Terms\License.txt", Encoding.UTF8))           {
....
}

此代码在 WPF 应用程序中工作正常。但当 ... 我使用 DesktopBridge 将 WPF 转换为 Appx,然后安装 .Appx。 相同的代码抛出异常。

Exception Info: System.IO.DirectoryNotFoundException.

有什么线索吗?有什么帮助吗?

此致

请参阅 MSDN 上的 Desktop Bridge 应用程序准备指南,并对您的应用程序进行适当的兼容代码更改:

https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-prepare

Your app uses the Current Working Directory. At runtime, your converted app won't get the same Working Directory that you previously specified in your desktop .LNK shortcut. You need to change your CWD at runtime if having the correct directory is important for your app to function correctly.

谢谢, Stefan Wick - Windows 开发者平台