lightningfire
lightningfire

Reputation: 117

Windows.Storage.ApplicationData.Current.LocalFolder.Path changes the path during normal debug and a test

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.

Upvotes: 1

Views: 3904

Answers (1)

Jayden
Jayden

Reputation: 3286

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 2xgss9‌​s9ewh1t. So the Package family name is ecb2e31f-f0a6-4cc5-8aa9-8cd1b887d5ed_2xgss9‌​s9ewh1t. 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.

Upvotes: 2

Related Questions