What is the path returned by the CurDir function
What is the path returned by the CurDir function
I thought it would return the current program's path, but I've used it and found that it often doesn't, sometimes it returns the "correct" path, sometimes it returns a different one, and I can't find any pattern to it .
-
- Posts: 109
- Joined: Mar 08, 2016 19:10
- Location: The Netherlands
Re: What is the path returned by the CurDir function
What OS are you using?
seems fine in windows 10 64bit
seems fine in windows 10 64bit
Re: What is the path returned by the CurDir function
I'm using windows 11
Re: What is the path returned by the CurDir function
Files are written or read in the current directory if you only enter the file name without the path.
Code: Select all
print "Path of the calling program:"
print "Exepath: ";exepath
print
print "Path of the current working directory:"
print "Curdir: ";curdir
print
print "Changing the current directory:"
chdir "C:\Windows"
print "Exepath: ";exepath
print "Curdir: ";curdir
sleep
Re: What is the path returned by the CurDir function
Thank you. Now I understand how theses functions workhhr wrote: ↑Nov 05, 2024 18:29 Files are written or read in the current directory if you only enter the file name without the path.Code: Select all
print "Path of the calling program:" print "Exepath: ";exepath print print "Path of the current working directory:" print "Curdir: ";curdir print print "Changing the current directory:" chdir "C:\Windows" print "Exepath: ";exepath print "Curdir: ";curdir sleep
-
- Posts: 8616
- Joined: May 28, 2005 3:28
- Contact:
Re: What is the path returned by the CurDir function
ChDir(ExePath())
after this CurDir() points to the exe path also.
Joshy
after this CurDir() points to the exe path also.
Joshy
Re: What is the path returned by the CurDir function
Note that browsing in a file selection window might change the path again as do some other widgets like directoryselect.
You would need to check your program and redo this every time after you call such widget. I gave up on it, and always use craft absolute paths instead, and not rely on curdir at all in GUI apps.
You would need to check your program and redo this every time after you call such widget. I gave up on it, and always use craft absolute paths instead, and not rely on curdir at all in GUI apps.