Stephane,
Here is code from where I did the same sort of thing. I don't know what's going
wrong with yours, but maybe this will help. The major difference here is I use
GetPathName() instead of GetPath().
CFileDialog FileList(TRUE, NULL, "*.XXX",OFN_HIDEREADONLY,
"XXX Files (*.XXX)|*.XXX|All Files (*.*)|*.*||");
CString temp;
CFile XXXFile;
CFileException e;
// Change the title to something more appropriate than "Read"
FileList.m_ofn.lpstrTitle = "Select a XXX File to Load";
if (FileList.DoModal() == IDOK) {
if(XXXFile.Open(FileList.GetPathName(),CFile::modeRead,&e)) {
...
}
Quote:
}
> I want to load a file. I have a Dialog with a "Load" button, i attach code
> to it :
> {
> // TODO ...
> CFile f;
> CFileDialog fd;
> fd.DoModal();
> f.Open(fd.GetPath(),CFile::modeRead | CFile::modeBinary);
> f.Close;
> }
> Well, this is maybe not exactly what I have typed in (maybe a
> letter or two are wrong), but it has built. Anyway, when i press the
> "Load" button, the application stops (not even closable), I have to
> kill it via Ctrl-Alt-Suppr.
> Thank you for your help.