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

Get help using Construct 2

Post » Thu Aug 04, 2016 12:27 am

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!
Last edited by suntank on Thu Aug 04, 2016 1:31 am, edited 1 time in total.
B
20
S
2
Posts: 70
Reputation: 1,446

Post » Thu Aug 04, 2016 1:21 am

It seems to work fine on my side.

Code: Select all
NWjs.AppFolder

Returns
Code: Select all
C:\Users\Username\Desktop\New project\win64

When the project is just exported to the desktop.

It also works for external drives:
Code: Select all
E:\win32

When I put the win32 folder on my USB drive.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Thu Aug 04, 2016 1:26 am

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
B
20
S
2
Posts: 70
Reputation: 1,446

Post » Thu Aug 04, 2016 1:35 am

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.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Thu Aug 04, 2016 3:10 am

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
B
20
S
2
Posts: 70
Reputation: 1,446

Post » Thu Aug 04, 2016 5:10 am

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
Code: Select all
"C:"&NWjs.UserFolder

Otherwise you would need to test for which directories have write permissions.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests