Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 21st, 2004, 05:01 AM
Registered User
 
Join Date: Sep 2004
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
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
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
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.