In a windows 2000,

How can I create File using relative path.

Let's say, the current path is c:\windows\folder\folder2\

and I am trying to make a file on c:\windows\another\example\.

so what is the relative path of "c:\windows\another\example\"

from "c:\windows\folder\folder2\

is it something like"..\..\another\example"?

:confused:
Posted on 2003-05-05 23:00:16 by Gandalf
yup .. moves you up one, if you start with a backslash your at the root. So to get to C:\windows\ from c:\windows\folder\folder2\ you have to go up two ..\..\ then specify the path from there \another\example so you have like you said ..\..\another\example

BTW this is the same in all windows and dos.
Posted on 2003-05-05 23:10:51 by donkey
I appreciate it, Donkey sir. :alright:
Posted on 2003-05-05 23:14:01 by Gandalf
Gandalf, be careful about depending on current folder though - some API calls can/do change it.

If you're working on something that might or will expand, and you're going to depend on eg program startup folder, it's a good idea to capture the initial folder at startup, and rather than using relative strings in calls, construct the full path from the initial-dir string and your relative path. It's (a bit) more work, but it pays off in the long end.

Furthermore, you can't depend on "GetCurrentDirectory at startup" to get the folder your program executable is located in - that will not handle the situation where a user has made a shortcut to your program and have specified another folder in the "start in" field.
Posted on 2003-05-06 02:15:37 by f0dder