Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Yesterday my software tester came across a very strange bug. I've been using CFileDialog for several Save As dialogs and he's found that although it stops you being able to save if you have '<:*?' in the filename, it allows '>'.

I can reproduce this just with :
CFileDialog dlg(FALSE);
if(dlg.DoModal() == IDOK)
    // By entering '>' for the filename and pressing "Save" I get here

I'm using VS2008 Standard with Win SDK v6.0a. I spent quite a while searching yesterday to find an explanation or solution, but couldn't find one. I've fixed the bug for now by deriving a custom CFileDialog which just overrides OnFileNameOK() and catches the '>' character. It's not very pretty and I'm not entirely happy with it because it ignores the source of the problem which is that CFileDialog isn't doing what it should.

Has anybody else come across this, or am I going mad? I'd be quite happy to accept that I've done something monumentally dumb. If anyone can shed any light on what's going on and how to make CFileDialog work as it should, I'd be really grateful.

I do not use MFC but tried to reproduce this using the GetSaveFileName() function, which is, I guess, what CFileDialog() uses under the covers. In every case it would not allow the '>' sign in the filename. I wonder if your local language setting accepts this character as legal in a filename, or if there is something else that makes it look like a valid character. I would suggest trying the GetSaveFileName() on your system to see if you get the same results.

I admit I'm clutching at straws here but just trying to think of places to look.
Share this answer
Thanks for the suggestion. Sorry for the delay in responding - I've been going through the joys of moving across to a new development machine.

In the course of this process, I've moved the code onto my new machine and just to confuse me even further, the bug is no longer present when compiled on the new machine.

I'm going to look into it a bit further when I get chance and then I'll post up what I find then.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900