2

Some temp files are being cached to Environment.GetFolderPath(Environment.SpecialFolder.) + "\\Company\\App";.

At app start the virtual AppData location is assigned. Everything seems to be okay and files are being generated in the virtual directory (C:\Users\User\AppData\Local\Packages\(hash)\LocalCache\Local\Company\App\file.file) as they should be.

After some time while trying to copy files in the same directory it throws:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\User\AppData\Local\Company\App\file.file.

The file exists in the virtual directory.

Am I missing something?

  • This is similar to https://stackoverflow.com/questions/67213866/packaged-wpf-app-returns-wrong-appdata-path-when-used-as-argument-for-a-new-proc/70895648#70895648 – Mark Ingram Jan 28 '22 at 15:05

1 Answers1

0

The app should be looking for the files in the real AppData folder only if the files were already present on the machine. (The real AppData folder has precedence over the virtual one).

Is the real AppData app folder empty/missing or are there any files there from previous tests? Can you reproduce this on a clean machine, in a VM for example?

Bogdan Mitrache
  • 10,536
  • 19
  • 34
  • The files and directories were never present on the real AppData/Local folder. And yes, this is reproduced on a clean machine. – Justas Puodžius Sep 23 '21 at 10:59
  • Do you have multiple EXEs inside your package or, are you launching another external EXE that might try to load the files from the incorrect location? (because it does not run in the virtual container of your app) – Bogdan Mitrache Sep 23 '21 at 13:32
  • No, that is not the case. Although, the app might try to access the files in a different thread. – Justas Puodžius Sep 24 '21 at 04:37