Solved

CFileDialog does not handle long extensions

Posted on 1998-06-08
6
219 Views
Last Modified: 2013-11-19
I would like to save files with extensions longer than three chars,  This is done by MFC with serialization.
When using CFileDialog (or for that matter the GetSaveFileName() API) extensions are limited to three chars due to the OPENFILENAME struct. What's up with that? (dont answer)
It is possible to use the SaveAs dialog and then append my own extension, but then I wont get the benefit of OFN_OVERWRITEPROMPT.
Any solutions?

Thanks.
Jeff
0
Comment
Question by:reichj
6 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1316251
It is not limited to three chars. Do you use the flag OFN_EXPLORER or OFN_LONGNAMES?
0
 

Author Comment

by:reichj
ID: 1316252
chensu,

I have tried both of those proir to posting the question.  Do you have a test app with CFileDialog or GetSaveFileName() working with long extensions? Maybe I'm doing something wrong but I've been through the OPENFILENAME doc's and aggree that OFN_LONGNAMES should produce the desired result, but it doesnt.
The doc's do say this about lpstrDefExt : "append this extension to the filename if the user fails to type an extension. This string can be any length, but only the first three characters are appended".
If you have a code snipet which works please post it.

Thanks,
Jeff
0
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1316253
What function do you use to get the filename from CFileDialog... GetPathName() ?

Do you call GetFileExt() to get the extension?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Accepted Solution

by:
mikeblas earned 150 total points
ID: 1316254
Actually, it's a bug in Win95. Longer extensions aren't supported by the box.  I think the problem was fixed in OSR2 of Win95.

B ekiM
0
 

Author Comment

by:reichj
ID: 1316255
Mike,

Is this bug documented? Is there an MSDN Q# or search keyword to find it?

So I guess to use >3 char extenstions I have to

(a) Not use OFN_OVERWRITEPROMPT
(b) append my own extension to the pathname, and
(c) Do my own overwrite protection (and dialog). Of course if the user doesnt want to overwrite I have to bring up the CFileDialog again to allow another filename selection.

or

Just overwrite without telling the user,  which generally does not go over very well.

Jeff


0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1316256
I don't know if it is documented; I don't think it is.

B ekiM
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 124
modThree challenge 4 79
Excel file not created as expected 7 50
Remove Password Protection from pdf (with password) using an command line executable 5 30
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now