wingedsoul
Programmer
Hi I am coding a program but having a problem with saving and loading parts of a text file. What I made is rite below and an error occurs "SFile file;". What is wrong? And if you can please give me some lines for loading a text file. Thank you!
void CSavePane::OnSaveButton()
{
static char filter[]="Text Files(*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog sDlg(FALSE,"txt","noname",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter);
if(sDlg.DoModal() != IDOK)
return;
CString str;
SFile file;
file.Open(sDlg.GetFileName(), CFile::modeCreate|CFile::modeWrite);
CArchive ar(&file, CArchive::load);
CArchive ar(&file, CArchive::store);
GetDlgItemText(IDC_DATA_EDIT,str);
ar<<str;
ar.Close();
file.Close();
SetDlgItemText(IDC_DATA_EDIT, "save ok!");
}
void CSavePane::OnSaveButton()
{
static char filter[]="Text Files(*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog sDlg(FALSE,"txt","noname",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter);
if(sDlg.DoModal() != IDOK)
return;
CString str;
SFile file;
file.Open(sDlg.GetFileName(), CFile::modeCreate|CFile::modeWrite);
CArchive ar(&file, CArchive::load);
CArchive ar(&file, CArchive::store);
GetDlgItemText(IDC_DATA_EDIT,str);
ar<<str;
ar.Close();
file.Close();
SetDlgItemText(IDC_DATA_EDIT, "save ok!");
}