Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Dirent.h

Reply
Thread Tools

Dirent.h

 
 
sargonisaac@gmail.com
Guest
Posts: n/a
 
      02-26-2006
I am trying to get Directory content list in VC++ 2003, here is my
code:

DIR *pdir;
struct dirent *pent;
char str[2000];
pdir=opendir("./users/" + FullName); //"." refers to the current dir
// if the dir doesnt exists, create it
if (!pdir){
mkdir("./users/" + FullName);
}

It says to use dirent.h and i cannot find it or it has not been found.
Can someone please help, am i doing something wrong or is there another
way of doing it???

 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      02-26-2006
wrote:
> I am trying to get Directory content list in VC++ 2003, here is my
> code:
>
> DIR *pdir;
> struct dirent *pent;
> char str[2000];
> pdir=opendir("./users/" + FullName); //"." refers to the current dir
> // if the dir doesnt exists, create it
> if (!pdir){
> mkdir("./users/" + FullName);
> }
>
> It says to use dirent.h and i cannot find it or it has not been found.
> Can someone please help, am i doing something wrong or is there another
> way of doing it???



This is not standard C++ - hence off topic in this NG.

Try a Microsoft NG -

perhaps:
microsoft.public.vc.language
 
Reply With Quote
 
 
 
 
Moonlit
Guest
Posts: n/a
 
      02-26-2006
Hi,

I might be wrong but I thought those functions are only available on unix.
Under windows use:

FindFirstFileEx

and friends.

Make sure to set the right WINNT version in the header otherwise you might
be pretty puzzled about the messages you get

_WIN32_WINNT 0x400

or something like that in StdAfx.h

--


Regards, Ron AF Greve

http://moonlit.xs4all.nl

<> wrote in message
news: oups.com...
>I am trying to get Directory content list in VC++ 2003, here is my
> code:
>
> DIR *pdir;
> struct dirent *pent;
> char str[2000];
> pdir=opendir("./users/" + FullName); //"." refers to the current dir
> // if the dir doesnt exists, create it
> if (!pdir){
> mkdir("./users/" + FullName);
> }
>
> It says to use dirent.h and i cannot find it or it has not been found.
> Can someone please help, am i doing something wrong or is there another
> way of doing it???
>



 
Reply With Quote
 
Larry I Smith
Guest
Posts: n/a
 
      02-26-2006
wrote:
> I am trying to get Directory content list in VC++ 2003, here is my
> code:
>
> DIR *pdir;
> struct dirent *pent;
> char str[2000];
> pdir=opendir("./users/" + FullName); //"." refers to the current dir
> // if the dir doesnt exists, create it
> if (!pdir){
> mkdir("./users/" + FullName);
> }
>
> It says to use dirent.h and i cannot find it or it has not been found.
> Can someone please help, am i doing something wrong or is there another
> way of doing it???
>


This is Unix/Linux code (DIR, opendir(), dirent).
Do the Microsoft headers/libs support/contain these functions
and structures?

Also, opendir() and mkdir() take C strings (char *) as their
args, not C++ std::string args. So the syntax like

"./users/" + FullName

won't work.

Larry
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57