CFileFind::Isdirectory() causes assertion

Hello, thanks for trying to help, I'm trying to use CFileFind::IsDirectory()
in a simple wrapper.function.  I think this used to work up until maybe the
last build but not sure.  The exception occured definitely when the
parameter was a file, and maybe also when the parameter was a directory.
Whatever.  This is the code:

BOOL ExistDirectory(CString strDirectory) {

 CFileFind FileFind;
 BOOL bWorking;
 bWorking = FileFind.FindFile(strDirectory);
 if (bWorking == TRUE) {
  //bWorking = FileFind.FindNextFile();
  if (FileFind.IsDirectory() == TRUE) {  // xxxxxxxx error!
CFileFind::IsDirectory causes assertion in asssertvalid
   return TRUE;
  }
 }
 return FALSE;
}

The assertion happens in AssertValid, called by IsDirectory() in the MFC
void CFileFind::AssertValid() const
{
 // if you trip the ASSERT in the else side, you've called
 // a Get() function without having done at least one
 // FindNext() call

 if (m_hContext == NULL)
  ASSERT(m_pFoundInfo == NULL && m_pNextInfo == NULL);
 else
  ASSERT(m_pFoundInfo != NULL && m_pNextInfo != NULL);

}

because pFoundInfo = NULL.

This couldn't be something of my doing, right?

Nothin in the MS Knowledgebase on any problem like that.

Anyone?  Anyone?  Bueller?

Thanks,

Ivan


0
ivan (57)
11/1/2003 3:38:24 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
495 Views

Similar Articles

[PageSpeed] 23

Never do == TRUE. TRUE is defined as 1 but anything not 0 is actually true.

Instead of: if (AnyFunction()==TRUE){

Just do: if (AnyFunction()){

Ruben

On Fri, 31 Oct 2003 22:38:24 -0500, "Ivan Starr" <ivan@ivanstarr.com> wrote:

>Hello, thanks for trying to help, I'm trying to use CFileFind::IsDirectory()
>in a simple wrapper.function.  I think this used to work up until maybe the
>last build but not sure.  The exception occured definitely when the
>parameter was a file, and maybe also when the parameter was a directory.
>Whatever.  This is the code:
>
>BOOL ExistDirectory(CString strDirectory) {
>
> CFileFind FileFind;
> BOOL bWorking;
> bWorking = FileFind.FindFile(strDirectory);
> if (bWorking == TRUE) {
>  //bWorking = FileFind.FindNextFile();
>  if (FileFind.IsDirectory() == TRUE) {  // xxxxxxxx error!
>CFileFind::IsDirectory causes assertion in asssertvalid
>   return TRUE;
>  }
> }
> return FALSE;
>}
>
>The assertion happens in AssertValid, called by IsDirectory() in the MFC
>void CFileFind::AssertValid() const
>{
> // if you trip the ASSERT in the else side, you've called
> // a Get() function without having done at least one
> // FindNext() call
>
> if (m_hContext == NULL)
>  ASSERT(m_pFoundInfo == NULL && m_pNextInfo == NULL);
> else
>  ASSERT(m_pFoundInfo != NULL && m_pNextInfo != NULL);
>
>}
>
>because pFoundInfo = NULL.
>
>This couldn't be something of my doing, right?
>
>Nothin in the MS Knowledgebase on any problem like that.
>
>Anyone?  Anyone?  Bueller?
>
>Thanks,
>
>Ivan
>

0
ruben4008 (24)
11/1/2003 8:26:45 AM
I agree. I have never found a situation in which comparing a boolean value to TRUE or
FALSE ever makes sense. I consider this a serious blunder in writing code. Since it never
makes sense (is the value TRUE == TRUE? Why ask the same question twice?) and because of
the implementation issue below, never, ever, under any circumstances, write == TRUE or ==
FALSE in any program. (While writing == FALSE actually works, it fools you into thinking
that if your test is wrong you can change FALSE to TRUE. This won't be guaranteed to work)

Whenever you report an ASSERT, you must (a) tell us what module and line it occured on
(your are told this information!) (b) if the assertion is not directly on a line of MFC
library source that says what is wrong, tell us what internal routine was involved [a huge
number of assetions go throuh assertvalid, but we need to know who called it, and why,
information which you have and we can only guess at) and (c) tell us the line in your code
that made the call. You only gave 1/3 of this information.
					joe



On Sat, 01 Nov 2003 09:26:45 +0100, Ruben J�nsson <ruben@minmail.net> wrote:

>
>Never do == TRUE. TRUE is defined as 1 but anything not 0 is actually true.
>
>Instead of: if (AnyFunction()==TRUE){
>
>Just do: if (AnyFunction()){
>
>Ruben
>
>On Fri, 31 Oct 2003 22:38:24 -0500, "Ivan Starr" <ivan@ivanstarr.com> wrote:
>
>>Hello, thanks for trying to help, I'm trying to use CFileFind::IsDirectory()
>>in a simple wrapper.function.  I think this used to work up until maybe the
>>last build but not sure.  The exception occured definitely when the
>>parameter was a file, and maybe also when the parameter was a directory.
>>Whatever.  This is the code:
>>
>>BOOL ExistDirectory(CString strDirectory) {
>>
>> CFileFind FileFind;
>> BOOL bWorking;
>> bWorking = FileFind.FindFile(strDirectory);
>> if (bWorking == TRUE) {
>>  //bWorking = FileFind.FindNextFile();
>>  if (FileFind.IsDirectory() == TRUE) {  // xxxxxxxx error!
>>CFileFind::IsDirectory causes assertion in asssertvalid
>>   return TRUE;
>>  }
>> }
>> return FALSE;
>>}
>>
>>The assertion happens in AssertValid, called by IsDirectory() in the MFC
>>void CFileFind::AssertValid() const
>>{
>> // if you trip the ASSERT in the else side, you've called
>> // a Get() function without having done at least one
>> // FindNext() call
>>
>> if (m_hContext == NULL)
>>  ASSERT(m_pFoundInfo == NULL && m_pNextInfo == NULL);
>> else
>>  ASSERT(m_pFoundInfo != NULL && m_pNextInfo != NULL);
>>
>>}
>>
>>because pFoundInfo = NULL.
>>
>>This couldn't be something of my doing, right?
>>
>>Nothin in the MS Knowledgebase on any problem like that.
>>
>>Anyone?  Anyone?  Bueller?
>>
>>Thanks,
>>
>>Ivan
>>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
11/1/2003 6:11:56 PM
Reply:

Similar Artilces:

Help: upgrade to Office XP SP3 causing: "A program is trying to access e-mail addresses...." alerts
Hi: I'm hoping that someone can help with this. After installing Office XP Service Pack 3, several users in the office are receiving the: "A program is trying to access e-mail addresses...." alerts every time an email is sent, . Anyone know what's causing this. The folks experiencing this are running Office XP, on WinXP pro, connected to an Exchange server Thanks for any advice. -- Dab Cut off: yourhead to respond Outlook 2002 SP3 adds additional properties to the list of those that are affected by the security features. As a result, one of your add-ins needs u...

problem with CFilefind
Hi all, I'm having a problem using the MFC's CFileFind class, so hope someone who knows would enlighten me. I'm trying to search for folders only, so the search wildcard is specified as "*.*" and I used the IsDirectory and IsDots to test when a directory is really a directory and not the DOS kind of dot or file. problem is, in my usage, I realize it always tend to miss one directory. even when searching for a file, it will tend to miss a file no matter what I do. Could someone please enlighten me on this? below I've attached some codes to detail how I used it....

Fill Style "Flow Normal" Causes printer error
With Visio 2003, diagrams containg symbols with the Fill Style set to "Flow Normal," cause a printer error. Is there a patch or work around for this? Thanks, Keith ...

Debug Assertion Failed (_CrtCheckMemory)
We have a console application which has been built with VC++ 6.0 (pure C++ project) and runs without any runtime errors. But when the same project has been ported to VC++ 7.0 environment, application asserts as "Debug Assertion Failed" (dbgheap.c, line 1100 & 346, _CrtCheckMemory). It continues to run, if the assertion is ignored at several places. Could anyone throw light on why this could happen specifically. (We have already digged through mixed usage of new, malloc, delete, delete[], free etc.,) If anything else corrupts heap memory, please suggest the same. Thanks ...

Could my ADODB connection be causing a network problem?
My employer's network is experiencing an unusual problem. An 8 mB write to the network drive takes about 8 seconds but reading the same file takes around 5 minutes. I'm wondering if the ADODB connection that I'm using (so that our parts room can log part issues to an access db) could be causing the problem? The db and the spreadsheet were created in Office 03 but the db is used nearly continuously in Office 07. The Spreadsheet is used nearly 24/6. I have included my code. Many many thanks in advance and Happy Thanksgiving Ted BTW There are 4 PC's (2-2007s...

SFO
Hi, We have an issue at the moment and wanted to check to see if anyone else was getting this before rasied a case with Microsoft directly. Basically when using the CRM Email button in SFO to create an email, we click on the Regarding button which brings up a search box where you can search for accounts/users etc. If you have an account in your CRM called Leeds & Birmingham (for example) we perform a search for 'Leeds & Birmingham' and it comes back with no results. If you search for 'Leeds' it finds the account and if you search for 'Leeds &amp;' i...

Cause/Fix of Outlook Abrubt Shut Down
Whenever Outlook performs an involved task, it abruptly shuts down. "Involved tasks" include things like archiving the folders, sending or receiving many or large messages, and processing dense or many rules. Only sometimes, an alert message will come up that states that a runtime error has occurred. The details of that error are below. This originally was only occurring on one of my computers, but now occurs on both of them. So far, I have done the following: - Scanned my computer for malware and found none - Used the Inbox Repair Tool (C:\Program Files\Common ...

SystemPens cause Exception error
Hi! This example is from e-learning. It cause exception error at line 3 when trying to change the DashStyle. The exception is translated to english "ArgumentException was unhandled It's not possible to make changes in the Pen because the priviligier are not valid" private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = this.CreateGraphics(); Pen pen = SystemPens.ActiveBorder; pen.DashStyle = DashStyle.Solid; pen.Width = 2; g.DrawLine(pen, 10, 10, 200, 10); pen.Dispose(); } So...

deletion causing crash...
Hi, In my home, I use Outlook (not express) with Win-2000. In recent past, I have received two similar mails that when I want to open, the Outlook crashes, I want to delete the mails - again Outlook crashes. In a hopeless situation, I have kept them in a folder 'can-not-delete'. Yesterday, I got another similar mail from a different person - finally, it is resting in 'can-not-delete' folder. In two out of three, the sender name do not appear in such mails. May I have some guideline for removing the mails physically? Thanks in advance, Poolak ------------------------...

form causes the db to close
A db was deigned on Access2003 and was working fine for a long time. I used it on Access2007 and converted to new format. Now when I open a specific form, the whole application terminates without any message. Event viewer doesn't record anything and if I try to save as 2003 format, many things are lost. it's called a crash if you don't like playing russian roulette with your data then move to SQL Server "Andreas" <ayiangoullis@hotmail.com> wrote in message news:1A213140-3D00-492E-8A55-415EC74F5185@microsoft.com... > A db was deigned on Access2003 and wa...

Copying Sheets causes errors
I have a quite extensive Excel workbook that I am using to track data and changes. I had made changes to a coupld of the pages on an older version of the document and wanted to keep those changes so I copied the sheets that I needed to the more current version of the document. As a result I have inadvertantly created links to the older version and it is messing me up. I have tried useing the "Break Links" under Edit and that doesn't seem to do anything. I am not wanting to have to redo everything but it looks like I am left with that being the only option. Does anyone...

What causes one loud continuous BEEP and system lock up?
Got a Dell Latitude D820, WXP, all service packs and drivers up to date. Lately, no matter what I might be doing (even walking away and doing nothing at all), the laptop will spontaneously freeze and there is a non-stop LOUD, continuous beep. You can't even push the power button and shut down. Must remove battery and/or unplug the stop the horrible noise. Sometimes it happens after being on the laptop 5 minutes, other times it won't happen until several hours have gone by. I have done some Google searches and even basic hardware diagnostics to no avail. Anybody ...

Cause : Unknown device driver
Okay...I have sort of figured out my most recent problems...I know a few people said not to mess with a Pole Display, but I'm still trying to make it work...I am going to post the problem, and if anyone can help with correcting it, I would greatly appreciate it. I know that I can disconnect the pole, but I want to see if there is a possible work around: C:\WINDOWS\Minidump\Mini012906-01.dmp C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\WER2.tmp.dir00\sysdata.xml BCCode : 1000008e BCP1 : C0000005 BCP2 : F96F05C5 BCP3 : F0D1DB74 BCP4 : 00000000 OSVer : 5_1_2600 SP : 1_0 P...

CFileFind
I am running a search for audio files that contain a given word in their names. In the case of the example provided here, there is only one filename containing "Ay.", and that is the file "Ay." (Ay..ogg). But after my wildcard search finds that file, it advances past it, so that FindNextFile( ) leaves me with no results. So actually, the same problem occurs with my successful searches. I never get to use the first file found. Would someone mind steering me into a better methodology here? CString word = _T("Ay."); CString s = GetFolderPath( ) ...

Formula addition causes random #REF!
I have added a new formula to ledger worksheets and now the #REF! appears in areas in the workbook. In order to fix it, all I have to do is copy a good cell with the formula (one that isn't showing #REF!) to on that is showing #REF! and all the cells in the workbook clear up. Any suggestions please? Thank you -- stevew It would help if we could see the formula best wishes -- Bernard Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme "stevew" <stevew@discussions.microsoft.com> wrote in message news:55417FE1-DF79-4A05-8C64-B9FD19159F82@micro...

What causes pixelated images in Publisher ?
I'm using Publisher 2002 to print an 8.5 x 11 inch document with approximately 30 high resolution photos on it. I've done this numerous times with great success. On this particular one, however, when I print it, about 10 of the images come out severely pixelated. Switching to another printer and computer didn't help. Initially I was using compressed JPGs for the photos (approx 300kb each). I went back to the original files from the camera (an 8 mp) which were approximately 4mb each, but that didn't help. What could be causing this problem ? Thanks Maybe this artic...

Help: What would cause this error message?
I have some file operation in my code, and i put an check an the end of code, then end up with: nErr = GetLastError(); //return nErr =183; Here is the system explain: // MessageId: ERROR_ALREADY_EXISTS // // MessageText: // // Cannot create a file when that file already exists. // // #define ERROR_ALREADY_EXISTS 183 But i could not find anything that cause this error after hours examination. Can anyone have this kind of experience show me some hints? Thank! We'd have to see some code leading to this to really help... what call is generating this error? -- Adam Clauss cabad...

Attachments open causes operation failed message
I have a user who gets an "Operation Failed" when opening attachments. However, when he tries again later, the attachmnet miraculously opens. We make no changes to the PC, just wait a few minutes and it opens....any ideas. Thanks Depending on the type of attachment, it may be a problem with adequate RAM or virtual memory. Perhaps he has too many programs open at the same time and if he's trying to open a Word attachment, it's having to struggle to find memory to open Word on top of everything else. Also, if the attachment is tied to an application that resides on the...

Resizing Pictures Causes Word to Jump to Beginning of Document
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hello - after I paste a picture and then change the text layout to &quot;tight&quot; Word typically jumps to the beginning of the document, sometimes taking the picture with it, sometime just putting the cursor up there. Any help on how this might be fixed would be appreciated. Go to Word>Preferences>View and turn on "Object Anchors" so you can see what you are doing. Then click the picture, and an Anchor symbol ⚓ will appear somewhere on the page where you pasted the picture. ...

EXCEL causes invalid page fault in vba332.dll
I can't seem to find any instances of this with Google - can anyone suggest a cause/solution? Excel causes an invalid page fault in VBA332.DLL when trying to display the Tools > Macro > Macros... or ...Record New Macro dialog box. Any suggestions gratefully accepted. Many thanks ghe[at]imail.barton.ac.uk ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ...

Using CFileFind over https?
I am trying to use CFileFind object to find a file located on a remote server having a URL like "https://RemoteDirectory/FileName.extn". This does not seem to work. However, the same approach workd for a File located at my local machine ( with the URL like "\\FolderName\FileName.extn"). Can the CFileFind class be used to search for files stored on https:// -like locations? If so, some sample code would help. If not, which class/API in MFC can be used for this task? No surprise, since it is not defined to work over an HTTP connection! Why would you expect that it coul...

Is "INDIRECT" the cause of these problems?
About 10 days ago via this medium I was shown how to count the # of worksheets using "INDIRECT". Since Monday I have been struggling with a workbook that seems self-corrupting. My workbook has about 100 worksheets; each worksheet contains an amortization schedule for the debt on a vehicle. All amortization schedules have an identical structure. Size of workbook is just under 30MB. Problem is the workbook will not open properly. Error messages include "cannot read file" and "damage to the file was so extensive that repairs were not possible". In my developme...

CFileFind Problem
Hello, I am having a problem with CFileFind under windows 2000. When I FindNextFile using a wild card *.* in a driectory the routine only finds other directories when there is only a single file in the directory. If there is more than one file in a directory the routine finds the files, Although I am not sure if it is dropping the first file listed in the directory. (haven't checked) Is this a known problem? Is there a patch? Thanks for any help. Peter Hi, Could you send some code, since this sounds like you might have a problem in your code. The CFileFind class works quite relia...

CFileFind in a thread
I'm doing some CFileFind operations in a worker thread. It's acting like even though it's threaded this operation is blocking the GUI thread because until all of these threads are complete the GUI is frozen. Is CFileFind the culprit or do I need to dig deeper? Post the code that's creating the thread. "Eric Margheim" <NOSPAM***eric@prism-grp.com***NOSPAM> wrote in message news:uHyurunsGHA.4608@TK2MSFTNGP04.phx.gbl... > I'm doing some CFileFind operations in a worker thread. It's acting like > even though it's threaded this opera...

Deleting causes illegal operation error
Suddenly and as far as I am aware without any input over the weekend, outlook express on my pc has decided that to delete email from my inbox is an illegal operation and I recieve the following message: MSIMN caused an exception c0000006H in module DIRECTDB.DLL at 0177:01bf5549. Registers: EAX=9a7a4820 CS=0177 EIP=01bf5549 EFLGS=00010202 EBX=024601b0 SS=017f ESP=0056e284 EBP=0056e29c ECX=0056e2d0 DS=017f ESI=024601a8 FS=67cf EDX=0fc14820 ES=017f EDI=01c16348 GS=0000 Bytes at CS:EIP: 89 10 8b 19 8b 4d 08 0f b7 0c 4d c8 14 bf 01 8b Stack dump: 01c16348 000018c0 00000005 00000019 00000000 0...