Hi,
I am trying to portablize a program. Everything is working fine, but for one thing. The program creates a file in the directory it opens a file from. So, lets say I open folder1\blah.ext the program will create "file.ext" in that folder. If I open a new file in let's say folder2\blahblah.ext it will create a new "file.ext" in that directory as well.
My question is how can I clean up those files on the exit of the program.
Thank you for the help.
You are here
Cleaning up after program opens file
August 8, 2014 - 3:34pm
#1
Cleaning up after program opens file
There is no way to do this with the PortableApps Launcher.
There may possibly be ways to do it with custom code, but I know very little NSIS and it sounds like it would fall in the range of complex to impossible, since you would have to hook into filesystem calls, determine which files were accessed (or created?) only by your program, record them somewhere, then clean them up on an exit hook.
I agree, this would have to be something you're doing while the app is running, not on close or start, which would be very messy to program using NSIS.
This seems like a very sloppy way of operating a program - what application is it that does this?
Hi,
The app saves the last four open files in registry. Is it possible to continuously read off a registry key while the program is running and record which folders the files are in.
Then the program can go down the list and remove the file from those folders.
If the application only stores the last four files, then not easily, no. If it was all recent files, it'd be easy to do (simply read the relevant registry key on close and delete the file in those locations), but not only the last four. PAL is unable to do a continuous action while a program is running as it simply runs ExecWait on the main application's exe after doing the start-up magic, and cleans up afterwards.
Again, which program is it? Maybe we can figure out another way to solve the problem if we can check it out ourselves as well.