getcwd behaves inconsistent?

Jonathan M Davis jmdavisProg at gmx.com
Sun Jun 17 17:33:50 PDT 2012


On Monday, June 18, 2012 00:38:59 Stephen Jones wrote:
> I recently switched from Eclipse to monoD and found that all my
> code to images etc was invalid because getcwd returns the
> directory that contains the main entry code in Eclipse, but
> returns the directory that contains the executable in
> MonoDevelop. Is there a universally consistent way of accessing
> files?

Yeah. They're called absolute paths and knowing where on the box the files are 
that you need to mess with.

But the reason that you're running into problems is that your IDEs are running 
your programe from different places. getcwd returns the current working 
directory, so if you don't change the directory while your program is running, 
it'l be where the program was started from. And if your IDE is controlling 
that, then you're going to have to figure out how to tell it start the program 
from where you wanted it started from,  which means finding the appropriate 
setting in the IDE (it's probably in the same spot where you tell it what 
arguments to give your program when it runs it).

- Jonathan M Davis


More information about the Digitalmars-d mailing list