C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 20th, 2002, 03:03 PM
Eclipce Eclipce is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2000
Posts: 763 Eclipce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 29 m 25 sec
Reputation Power: 0
Reading a Directory in Windows?

Hello,

I am familiar with opendir, readdir, ect. that linux uses. However, I would like to know what functions and headers to use to read a directory in a windows enviroment. I have tried searching the msdn, but I have not had any luck yet.

Eclipce

Reply With Quote
  #2  
Old May 20th, 2002, 03:30 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
I think winbase.h defines these functions.

Code:
WIN32_FIND_DATA fd;
HANDLE hFind = ::FindFirstFile("c:\mydir\*.*", &fd);

if (hFind != INVALID_HANDLE_VALUE) // make sure valid
{
    do
    {
        if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // don't care about directories
            MyFunction(fd.cFileName);
    } while (::FindNextFile(hFind, &fd)); // enumerates contents
    ::FindClose(hFind);
}


I've only used them in MFC, so the framework may have automatically imported other necessary libraries, etc. Either way, if you look the MSDN with the above functions, I'm sure you'll figure it out. If you need to enumerate through sub-directories too, check the SetCurrentDirectory() function too.

Reply With Quote
  #3  
Old May 20th, 2002, 07:58 PM
Eclipce Eclipce is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2000
Posts: 763 Eclipce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 29 m 25 sec
Reputation Power: 0
Thanks a bunch!

Eclipce

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Reading a Directory in Windows?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway