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.
-
What are the two respective paths? Can you print them to Debug output or to a log file somewhere? – Jens Meinecke Jan 26 '16 at 04:23
-
You are trying to use system path or relative to LocalFolder? – Romasz Jan 26 '16 at 08:49
-
The normal debug path gives me this: C:\Users\Home\AppData\Local\Packages\ecb2e31f-f0a6-4cc5-8aa9-8cd1b887d5ed_2xgss9s9ewh1t\LocalState The test gives me: C:\Users\Home\AppData\Local\Packages\c110be4d-26ac-4a4e-9c34-952c8f5ebd9d_2xgss9s9ewh1t\LocalState – lightningfire Jan 26 '16 at 13:36
-
Why does your unit test need a file from app's `LocalFolder`? Unit tests should initialize all the required data themselves. – Damir Arh Jan 27 '16 at 06:46
1 Answers
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.
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
.
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.

- 46,945
- 8
- 85
- 181

- 3,276
- 1
- 10
- 14