Solved

CFileException

Posted on 1998-12-29
2
1,077 Views
Last Modified: 2013-12-03
I'm trying to catch "end of file" by using CFileException.
I have code in a try/catch block and when EOF occurs the catch part doesn't work.  My program goes on forever in what appears to be an endless loop.  Any working examples or help would be greatly appreciated!  Thanks, Kelvin
0
Comment
Question by:drivers102797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1417829
Post your code here, so we can see what is wrong and try to fix it
0
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1417830
Sorry, no exception is thrown when EOF is reached (as this isn't necessarily an error). To detect this, check the return value of 'CFile::Read()'. If it is less than the number of bytes requested, you're at the end...
begin quote-->
CFile::Read
virtual UINT Read( void* lpBuf, UINT nCount );
throw( CFileException );

Return Value

The number of bytes transferred to the buffer. Note that for all CFile classes, the return value may be less than nCount if the end of file was reached.

<-- end quote

Feel free to ask if you need an example...

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question