Is there a proper way to locate Windows Standard Folders? e.g. AppData, etc.

In the Daz portion of my SketchUp importer i have a need to reliably locate the current user's AppData folder.  So far the only script functionality I have been able to find is 'App.getAppDataPath()', which returns a path that is (apparently) actually 2 levels down after AppData/Roaming itself.  By way of illustration, on my system this is 'C:/Users/mjenkins/AppData/Roaming/DAZ 3D/Studio4'.

So what I am doing (right now) is taking this path and going up 2 levels, which does take me to 'C:/Users/mjenkins/AppData/Roaming', which is where I need to be.  However I am not convinced that this is a reliable method for getting this path, as it's my impression that Daz's AppDataPath may not always point here.

So, my question: Is there any way in Daz Script to simply ask the operating system for the location of standard folders, such as AppData?

Thanks in advance.

Regards,
Mike

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,888

    As far as I know applications should not make changse putside their AppData folder. That said, it is possible to access the environment variables through (as I recall) DzSystem.

  • ModelerMJModelerMJ Posts: 41

    System.getenv("APPDATA") does indeed give me what I'm after.  Thank you once again!

    My software does have its own folder within AppData\Roaming, and (other than the user-specified SketchUp model folders) that is the only place it writes information to.  This folder is used to communicate various information between the SketchUp part and the Daz part to provide increased convenience of operation (for example, the Daz part can automatically determine where the SketchUp part created the most recent export, so the user doesn't have to manually browse to that location).  That's why I needed to be able to locate it in my Daz script.  Once I find AppData\Roaming, I append my own folder name to that and work from there.

    Regards,
    Mike

  • HowieFarkesHowieFarkes Posts: 607

    Be aware that System environment variables are OS specific. System.getenv("APPDATA") on Mac returns nothing.

  • ModelerMJModelerMJ Posts: 41
    edited June 2017

    It is a Windows-only application, but thank you for the information.

    Regards,
    Mike

    Post edited by ModelerMJ on
Sign In or Register to comment.