|
#1
|
|||
|
|||
|
obtain current file directory
I'm currently using the following code to obtain the current directory.
is there a better C++ way of doing this? is there such a thing as #include <direct>? Code:
#include <direct.h>
char buffer[_MAX_PATH];
/* Get the current working directory: */
if( _getcwd( buffer, _MAX_PATH) == NULL)
{
cout<<( "_getcwd error on file" + filein );
exit(0);
}
else
{
path = buffer; // path is string
}
System.getProperty("user.dir") System.getProperty("file.separator") Thanks! Last edited by rssmps; 10-07-2005 at 02:55 PM. |
|
#2
|
||||
|
||||
|
There's "dir.h" and "dirent.h" but they both use getcwd(). Alternatively, you can use the getenv() function to obtain the current directory, if you you its symbolic name:
const char * pdir= getennv("path");
__________________
Danny Kalev |
|
#3
|
|||
|
|||
|
I'll give these a try....and report back if there are any problems.
for the code that I have above and the dir.h/dirent.h standard libraries, are these libraries win specific or standard across platforms? Thanks! |
|
#4
|
||||
|
||||
|
they aren't officially standard but in practice, both Windows and POSIX systems support them, so they are pretty portable.
__________________
Danny Kalev |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| directory listing to text file | kgkidd | VB Classic | 2 | 09-19-2005 03:17 PM |
| Monitoring directory for new file and launch application | Niklas E | VB Classic | 0 | 03-17-2001 01:47 PM |
| Send File object thru ObjectOutputStream ObjectInputStream | Lim Wing Hoe | Java | 2 | 12-27-2000 05:22 AM |
| ASP creates HTML file, How can I get FrontPage to import it? | Phil | ASP.NET | 3 | 05-31-2000 11:30 AM |
| Making a single jar file from differnet packages | M.S.Ramagopal | Java | 0 | 05-02-2000 04:39 AM |