Link to home
Start Free TrialLog in
Avatar of VSmolensky
VSmolensky

asked on

Why do folders created in UWP apps seem non-existent?

My Delphi application for Windows is packed in appx so I can have it published in Microsoft Store. At the first run, the app creates a folder in <user>AppData\Roaming to store there some files accessible for the users. Here's the code:

MyFolder:=GetSpecialFolderPath(CSIDL_APPDATA)+'\MyApp';
CreateDir(MyFolder);
TDirectory.SetAttributes(MyFolder,[TFileAttribute.faNormal]);

Open in new window


It works fine. When the app is running, the users can open its dialog windows, see this folder with all the files, read them or write into them. But only from the app! The mystery is that this new folder cannot be seen in Windows Explorer. Even in Command Prompt it seems non-existent!

Can anybody explain what this means?
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VSmolensky
VSmolensky

ASKER

No, it's not. The folder <user>AppData\Roaming is NOT hidden. I can easily see it in Windows Explorer with all its subfolders, except MyApp.
Do you have show hidden files and folders enabled in win explorer?
try to create folder with: ForceDirectories(MyFolder)
...and even more ... show message with path before creating folder before creating... then you be sure where it is...

MyFolder:=GetSpecialFolderPath(CSIDL_APPDATA)+'\MyApp';
ShowMessage(MyFolder);
ForceDirectories(MyFolder);
...

Open in new window

ForceDirectories in my case works just like CreateDir. No difference.

But you are absolutely right about the hidden nature of AppData! It looks like even when it's not hidden in my Windows Explorer, it still works in a very special way with its subfolders. I've just replaced CSIDL_APPDATA by CSIDL_COMMON_APPDATA, and everything is fine now! All the files go to C:\ProgramData\MyApp and I can easily see them from any place.

Thank you very much for the right direction of thinking!