Windows.Storage.ApplicationData.Current.LocalFolder.Path 在正常调试和测试期间更改路径 [英] Windows.Storage.ApplicationData.Current.LocalFolder.Path changes the path during normal debug and a test
问题描述
我正在创建一个 UWP 应用程序并使用 Windows.Storage.ApplicationData.Current.LocalFolder.Path 作为路径创建了一个文件.在调试模式下,它有一个路径位置,然后在运行单元测试时,它有一个不同的路径位置,因此不会找到文件,因为它是一个不同的位置.有没有人遇到过这个?我一直在搜索,但没有看到任何关于它为什么在调试和调试单元测试之间这样做的信息.
I am creating a UWP app and have created a file using Windows.Storage.ApplicationData.Current.LocalFolder.Path for the path. When in debug mode, it has one location for the path, then when running a unit test, it has a different location for the path and therefore will not find the file since it is a different location. Has anybody encountered this before? I've been searching and haven't seen anything on why it does this between debugging and debugging a unit test.
推荐答案
每个项目都有不同的包族名
.LocalFolder.Path
基于调试中的Package family name
.您的调试项目 Package name
是 ecb2e31f-f0a6-4cc5-8aa9-8cd1b887d5ed
并且 PublisherId
是 2xgss9 s9ewh1t
.所以Package family name
是ecb2e31f-f0a6-4cc5-8aa9-8cd1b887d5ed_2xgss9 s9ewh1t
.unit test
是另一个项目,所以它有一个不同的Package family name
.有关详细信息,请参阅包系列名称.
The each project has different Package family name
. And the LocalFolder.Path
is base on the Package family name
in debug. Your debug project Package name
is ecb2e31f-f0a6-4cc5-8aa9-8cd1b887d5ed
and the PublisherId
is 2xgss9s9ewh1t
. So the Package family name
is ecb2e31f-f0a6-4cc5-8aa9-8cd1b887d5ed_2xgss9s9ewh1t
. The unit test
is another project, so it has a different Package family name
. For more info, see Package family name.
文件夹是由第一次调试创建的.您可以在 Package.appxmanifest
中更改 Package name
.LocalFolder.Path
将在您再次调试时发生变化.并且文件夹将更改为新的Package family name
.
The folder is created by first debug. You can change Package name
in Package.appxmanifest
. The LocalFolder.Path
will change when you debug it again. And the folder will change to the new Package family name
.
单元测试项目在调试时无法创建文件夹.但是它可以获取不存在的 URI 的 LocalFolder.Path
.
The unit test Project can not create the folder when you debug it. But it can get the LocalFolder.Path
that is a non-existent URI.
这篇关于Windows.Storage.ApplicationData.Current.LocalFolder.Path 在正常调试和测试期间更改路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!