Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 21st, 2004, 05:01 AM
Registered User
 
Join Date: Sep 2004
Location: , , India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default reading file names

I wanted to kno how to read a directory structure to get the names of files in a particular directory.
Im using windows XP and VC++, and i would like to get the names of all files present in C:\TEMP directory

Thnx and regards
ritesh
Reply With Quote
  #2 (permalink)  
Old September 21st, 2004, 05:24 AM
Authorized User
 
Join Date: Dec 2003
Location: Bristol, , United Kingdom.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Findfirst will do this for you:

#include <dir.h>

struct ffblk ffblk;
int done;

done = findfirst("C:\\TEMP\\*.*", &ffblk, 0);

while (!done)
{
   printf("%s\n", ffblk.ff_name);
   done = findnext(&ffblk);
}





Georges
Reply With Quote
  #3 (permalink)  
Old September 22nd, 2004, 12:09 AM
Registered User
 
Join Date: Sep 2004
Location: , , India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Georges
that works on a DOS machine...
i found out that _findfirst and _findnext of io.h have to be used...
thnx for the info though
Reply With Quote
  #4 (permalink)  
Old September 22nd, 2004, 05:13 AM
Authorized User
 
Join Date: Dec 2003
Location: Bristol, , United Kingdom.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, well it depends on the compiler - I use Borland 5.02. Obsolete now of course but still going strong! Glad it solved the problem albeit indirectly.

Georges
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print directory file names in a loop ypomonh XSLT 2 May 14th, 2007 05:47 AM
file names page 664 levelmeasure BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 March 16th, 2006 04:33 PM
using php to check file names fogofogo PHP How-To 0 February 20th, 2006 06:15 AM
changing Text source file names rjjhome SQL Server DTS 1 August 18th, 2004 02:27 PM
file names (close enough) tontos Classic ASP Basics 1 July 25th, 2004 08:14 PM



All times are GMT -4. The time now is 03:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.