Skip to content

WASM: directory created using CreateDirectory does not exist after restart #4987

Answered by MartinZikmund
stefanolson asked this question in Q&A
Discussion options

You must be logged in to vote

@stefanolson I have tested the code and found the reason why the folder disappears. In WASM, folders that are persistent across launches need to be specifically marked. This is the case for folders under ApplicationData - for example LocalFolder and RoamingFolder (see here for the code). This is the reason the folder created using the StorageFolder API persists - because it is under the ApplicationData.LocalFolder.Current path.

To allow your System.IO folder to persist as well, you need to create it under the same path:

var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, systemIoFolderName);

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jeromelaban
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #4958 on January 21, 2021 12:32.