I’m writing a program that needs to access a file inside of c:\program files\program_name\.
My target file will always be inside of \program_name\program_name\bin\something.exe
However, because the program is extracted from an archive, if the user unpacks it improperly, it’ll be simply \program_name\bin\something.exe, skipping a whole level.
Currently I’m basically getting the contents of c:\program files\, collecting the names of all folders that contain program_name, then adding them to the list and then using the list to loop through each one of those seeing if there’s a program_name inside of it, etc, which should eventually lead me to the result.
Basically I’m creating large chunks of code for each individual possibility. Is there a smarter way to go about this?
Sounds like you could benefit from having an installer that writes to the registry. Then you’ll know where all the files and folders are, even if the user installs to a weird location.