F
F
fralik2020-11-02 14:40:54
Windows
fralik, 2020-11-02 14:40:54

How to save user data from C# in modern windows applications (store, msix)?

I have an application (.net core 3.1) that is packaged with msix and needs to be distributed via the windows store. When I run the application, I need to download some files from the internet. Where can they be saved?
The documentation only says that the application runs in an isolated container. I have tried writing to

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
, but I get aceess denied. On the test machine, this path resolves to C:\Program Files\WindowsApps\..., and you cannot write there.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fralik, 2020-11-02
@fralik

UWP has a function that returns a writable folder. But my program itself is written in .net core, so this option is no longer available. The fact that it runs as UWP doesn't help.
Found documentation that describes two methods:

  1. You can write and read through Environment.SpecialFolder;
  2. You can read files added to the project.

The problem, as is often the case, was in my code. Or rather, in the library that I use. It downloads files through a console utility, which is not allowed for UWP apps. If not for this, then I could write to , otherwise I would have SpecialFolderto add all the necessary files to the package.

A
antonwx, 2020-11-02
@antonwx

In %appdata%\yourAppName?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question