I wanna Write data into .txt file created by CFileDialog, in C++.
The problem I am facing is that below codes doesn't work, although there is no build error. The .txt file created by CFileDialog can not be found for some reason. What's wrong the code?
what's the efficient way to Write data into .txt file created by CFileDialog, in C++?
Thanks
CFileDialog dlg(FALSE, NULL, NULL, OFN_OVERWRITEPROMPT,
_T("My Data File (*.txt)|*.txt||"));
if(dlg.DoModal() != IDOK)
return;
CString filename = dlg.GetPathName();
ofstream outfile (filename);
int mydata = 10;
outfile << "my data:" << mydata << endl;
outfile.close();