Forum Discussion
PSF FileRedirectionFixup not working as intended?
Hi All,
I need some help. I have an application that writes to and reads from ProgramFilesX86\ApplicationDir, there's an INI file stored there which contains all the database settings for the application to function. The APP always looks to ProgramFilesX86\ApplicationDir for this file, but it cannot edit it here, by design.
I've use the PSF and a FileRedirectionFixup to redirect requests for that file to another location. I've pasted the code of my config.json file below. I've placed my INI file that I need read by the application within the redirected folder, but the application still fails.
{
"processes": [
{
"executable": ".*",
"fixups": [
{
"dll": "FileRedirectionFixup",
"config": {
"redirectedPaths": {
"packageRelative": [
{
"base": "VFS\\ProgramFilesX86\\IMPAC\\METRIQ",
"redirectTargetBase": "C:\\IMPAC\\METRIQ",
"patterns": [
"IMSPHospital\\.ini"
]
},
{
"base": "VFS\\ProgramFilesX86\\IMPAC\\METRIQ\\Logs",
"redirectTargetBase": "C:\\IMPAC\\METRIQ\\LOGS",
"patterns": [
"ErrLog\\.log"
]
}
]
}
}
}
]
}
]
}
Is my PSF config.json file wrong, or am I misunderstanding what fileRedirectionFixup will do for me?
My final possibility is there's somethin in the read code of the application looking for this INI that is different than what fileRedirectionFixup is going to handle, and if this is true then I'm going to abandon the msix packaging for this app.
13 Replies
- Darren_Hoehna
Microsoft
HeyJohn Wildes ,
Thank you so much for using the Package Support Framework. It makes me happy when I hear people using it.
Quick question before I mention a solution. Does this ini file exist before the app is started or is it made while the app is running?
- John WildesBrass Contributor
Darren_Hoehna , so normally it would. When the application starts, it checks to see if there's an INI file, if it doesn't exist then it creates one.
If one exists, but is blank (no meaningful data no connection strings) it brings up a configuration screen upon startup that asks the user to fill in database server, db, auth information. We don't want this at all. However, if I include an INI that has prepopulated strings and database information in it (which would be different for every customer) it poses a problem.
- Darren_Hoehna
Microsoft
I see. So, what you want PSF to do is to find the ini file is ProgramFilesX86/ApplicationData, right?
The FRF works differently than what we naturally think as redirection.
FRF takes the path we want to redirect and PSF takes care of the redirection for us. An example from your configuration file.
{ "base": "VFS\\ProgramFilesX86\\IMPAC\\METRIQ", "redirectTargetBase": "C:\\IMPAC\\METRIQ", "patterns": [ "IMSPHospital\\.ini" ] },This is telling PSF to redirect all file operations in VFS\ProgramFilesX86\IMPAC\METRIQ to C:\IMPAC\METRIQ for all files that match the pattern IMSHospital\.ini.
What we want to do is tell PSF to redirect all file operations in ProgramFilesX86\ApplicationData that match the pattern IMSHospital\*.ini.
Because ProgramFilesX86 is a known folder I would suggest to use the known folder options instead.
Your configuration would look like this.
"config": { "redirectedPaths": { "knownFolders": [ { "id": "ProgramFilesX86", "relativePaths": [ { "base": "ApplicationData\\IMSHospital", "patterns": [ ".*" ] } ] } ] } }
Can you please try that and get back to me?
- John WildesBrass Contributor
What seems to be happening here is that it's still reading from the ProgramFilesX86\ApplicationData folder, and writing to the location I've specified. However when I close the app and run it again, over writes the data in the redirected folder and I have to run my initial INI configuration over and over. Why can't it just read from the redirected location, after I've saved an INI file there?