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++ > Visual C++
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 August 31st, 2006, 08:20 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to read files in evc++

Hi,
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") ) );

hFile = CreateFile(wszBuf, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, 0);
WriteFile(hFile, filedata, dwFileSize, &dwBytesWritten, NULL);
CloseHandle(hFile);
}
//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))
{
ShowLastError();
return(0);
}

CloseHandle(hFile);
}
dwEndTick = GetTickCount();

}

is it right way to do that?

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

Reply With Quote
  #2 (permalink)  
Old September 1st, 2006, 04:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Default

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
ok.
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.

Regards
Ankur
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
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



All times are GMT -4. The time now is 08:20 PM.


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