-2

I have a Windows Form app that I converted to UWP that includes a log file. If the log file does not exist an empty log file is created on startup. For the Windows Form version the log file is created in the users’ AppData folder. For the UWP the log file is being created in the redirected folder C:\Users\UserName\AppData\Local\Packages\AppName_Plus_Random_Characters\LocalCache\Roaming\Company_Name\App_Name. I have read/write access to the log file within both versions of the app.

To allow the user to view the log file, from within the app, the app calls the users’ .txt app (normally NotePad). This works in the both versions but with the UWP version NotePad is receiving the original Windows Form path to the AppData folder to the log file not the UWP redirected path. If an old log file exists in the users’ AppData folder, from a previous execution of the Windows Form version, NotePad will open the old log file when called from the UWP.

How can I get the UWP version to send its’ redirected path for the log file to NotePad?

Window Version 17134.112 Base Image Windows_BaseImage_DAC_17134.wim

1 Answers1

0

How can I get the UWP version to send its’ redirected path for the log file to NotePad?

If you want to get redirected path of converted WinForm App, you could use the modern ApplicationData API for both read and write and you won't need to know about the actual location. Such as Roaming that used in your case. You could get it like the follow.

var foloder = ApplicationData.Current.RoamingFolder;

Then you could use Windows.Storage to get file from the folder base on the above. For ApplicationData please refer this. For Windows Storage refer this.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36