Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ 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
Old August 31st, 2006, 08:20 PM
Registered User
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to read files in evc++

i am trying to check how long it takes to read files from sd card.

i create 100 files 10k each

for(i = 0;i<100;i++)
wsprintf(wszBuf, _T("%s\\Filetest_%d.txt"), g_szVolume, i);
RETAILMSG( 1, ( wszBuf ) );
RETAILMSG( 1, ( _T("\r\n") ) );

WriteFile(hFile, filedata, dwFileSize, &dwBytesWritten, NULL);
//end create file

dwStartTick = GetTickCount(); //Get initial tick count

//We are going to Open/Close the file for every file read.
for (i=0; i<dwInterval; i++)

wsprintf(wszBuf, _T("%s\\Filetest_%d.txt"), g_szVolume, i);
RETAILMSG( 1, ( wszBuf ) );
RETAILMSG( 1, ( _T("\r\n") ) );

hFile = CreateFile(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);

if(!ReadFile(hFile, &filedata_readed, dwFileSize, &dwBytesWritten, NULL))

dwEndTick = GetTickCount();


is it right way to do that?

How can i open directory and to get list of all files?

Old September 1st, 2006, 04:19 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma

You have to see how precise you want the results to be.
For this code to give you precise results you'll need to
keep your system free. Like if your system is also doing
some heavy processing simultaneously then the results will
show you that. May be thats what you want in which case its
In any case you may want to make it into a critical section.
To make your time span calculation more precise you can explore
the use of QueryPerformanceCounter and QueryPerformanceFrequency.

Use FindFirstFile, FineNextFile to get files in a directory.


Similar Threads
Thread Thread Starter Forum Replies Last Post
read pdf files in C# prasannatele Visual Studio 2005 0 September 12th, 2007 05:46 AM
How to read file line by line in EVC++ iriskab Visual C++ 0 September 27th, 2006 01:39 PM
Writing Files that can't be read Ron_Bingham BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 April 23rd, 2005 02:25 PM
Opening Files Read-Only SerranoG Access VBA 5 May 6th, 2004 02:40 PM

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