NodeWebkit Relative Path

Get help using Construct 2

Post » Fri Feb 20, 2015 4:39 am

I have a file that I would like to manipulate using NodeWebkit, but I'm having problems finding the file when using a relative path.

Example: I have a global variable (dataPath) with the path to the file and two events that display "True" if it can find the file or "False" if it can't.

When dataPath is set to "C:\datafolder\file.txt", it displays "True".

When dataPath is set to "..\datafolder\file.txt", it displays "False". (this is with the game files exported and running from C:\gamefolder)

So my directories looks like this:

Code: Select all
C:\datafolder\file.txt
C:\gamefolder\game.exe


Is there any reason this shouldn't work? What am I missing?
B
5
S
2
Posts: 37
Reputation: 699

Post » Fri Feb 20, 2015 7:27 am

Have you tried adding another ..
"..\..\datafolder\file.txt"
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Post » Fri Feb 20, 2015 2:53 pm

I haven't, but I don't feel like that makes any more sense?

".." should go back one directory, right? So if I'm running the exe out of "C:\gamefolder", I would step back into "C:\", then up into "C:\datafolder". How would the extra ".." help?

I'm away from my computer for now, but I suppose I'll try it later.
B
5
S
2
Posts: 37
Reputation: 699

Post » Fri Feb 20, 2015 6:44 pm

Try
Code: Select all
NWjs.AppFolder & "..\datafolder\file.txt"
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620

Post » Fri Feb 20, 2015 6:58 pm

Ignore me, I was miss reading your original post.
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Post » Fri Feb 20, 2015 7:15 pm

ramones wrote:Try
Code: Select all
NWjs.AppFolder & "..\datafolder\file.txt"


I'm fairly certain I tried that as well, but I'll give it another shot when I get home.
B
5
S
2
Posts: 37
Reputation: 699

Post » Fri Feb 20, 2015 11:25 pm

I tried this:

Code: Select all
NWjs.AppFolder & "..\datafolder\file.txt"


And still no dice. I'm thinking I could probably work around it by saving that NWjs.AppFolder and stripping out the last foldername with tokenat, but I was hoping the tried and true ".." would work since it's obviously much less work. :/
You do not have the required permissions to view the files attached to this post.
B
5
S
2
Posts: 37
Reputation: 699

Post » Fri Feb 20, 2015 11:40 pm

It works for me. Have you got a "datafolder" folder created?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, dimulcu, just2pale, plinkie, Xh3maa and 3 guests