How do I get nwjs to return the user folders drive letter?

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Here is a demonstration capx: https://www.dropbox.com/s/ce0h75sc1k66wu8/nwjsGlitch..capx?dl=0

    As it is currently, nwjs.userfolder does not return "C:\" but instead returns "/users/username" which doesnt work for loading sprite images off the hard drive. However nwjs.appfolder does work in this way and does return "C:\" and images can load just fine from there (assuming the user has granted access which is why I can't use this option)

    Anyone have any ideas? I did try just adding in "C:\"& before using nwjs.userfolder and obviously this works except in a scenario where the player does not have windows installed to drive C or just simply renamed the drive.

    Anyone have a workaround or idea to solve this? thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It seems to work fine on my side.

    NWjs.AppFolder[/code:13lu71wk]
    Returns
    [code:13lu71wk]C:\Users\Username\Desktop\New project\win64[/code:13lu71wk]
    When the project is just exported to the desktop.
    
    It also works for external drives:
    [code:13lu71wk]E:\win32[/code:13lu71wk]
    When I put the win32 folder on my USB drive.
  • Well yeah I mentioned that nwjs.appfolder does in deed work just fine. It's the nwjs.userfolder option that I was having the issue with

  • Hmm, so you're trying to find the user's user folder path?

    That's tricky. Is there any particular reason you need to use the user folder?

    Personally, I would just try to use C drive, and if that failed (incorrect path) then use the current folder. As far as I can tell NWjs isn't capable of finding the Windows drive letter.

  • Well it does when you use nwjs.appfolder expression. just not with nwjs.userfolder expression. I have no idea why. I could use the appfolder expression except that not everyone has permission to read and write to program files. whereas everyone can read and write to the user folder. That's the dilemma

  • So I just found out it's actually not possible to change the operating system drive letter. As far as I can tell it's hard-coded.

    You should be fine using

    "C:"&NWjs.UserFolder[/code:cgg2e6ck]
    Otherwise you would need to test for which directories have write permissions.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)