I came across a funny problem today. A client wants a plugin to store application in the “C:/Program Files” directory.
I use the command:
const String appDirPath = File::getSpecialLocation(File::globalApplicationDirectory).getFullPathName() + “\MyProgramName”;
I DBG the string to make sure it’s correct:
… it is (correctly) “C:\Program Files\MyProgramName”
I do a check …
which comes back true …
then create the directory …
which also comes back true.
However … the directory is not created.
Not so surprising, since you need administrator privileges to create a directory in “Program Files” … but since hasWriteAccess() came back true, and the createDirectory command came back true … I am stumped as to how to indicate what went wrong.
One other note :::
I tried using the File::separatorString (instead of the “//”) … but for some reason this causes the plugin to be unloadable! Perhaps adding two const Strings in a header is a problem … not sure why that would be … but I tried it several times and every time the plugin would suddenly refuse to load …huh.