一、读文件
CStdioFile InputFile;
CString InputFilter;
CString InputFilePath;
CString str;
InputFilter = _T ( "Data Files(*.wts)|*.wts||" ) ; CFileDialog MyDialog ( TRUE, 0 , 0 , OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, InputFilter) ;
if ( IDOK == MyDialog. DoModal ( ) )
{ InputFilePath = MyDialog. GetPathName ( ) ; InputFile. Open ( InputFilePath, CFile:: modeReadWrite) ; InputFile. ReadString ( str) ; bpnn-> mNumInputs = _wtoi ( str) ; InputFile. Close ( ) ;
}
二、写文件
CStdioFile OutputFile;
CString OutputFilter;
CString OutputFilePath;
CString str;
int pos;
OutputFilter = _T ( "Data Files(*.wts)|*.wts||" ) ;
CFileDialog MyDialog ( FALSE, 0 , 0 , OFN_OVERWRITEPROMPT, OutputFilter) ;
if ( IDOK == MyDialog. DoModal ( ) )
{ str = MyDialog. GetPathName ( ) ; pos = str. Find ( _T ( ".wts" ) ) ; if ( - 1 != pos) str = str. Left ( pos) ; OutputFilePath = str + _T ( ".wts" ) ; OutputFile. Open ( OutputFilePath, CFile:: modeCreate | CFile:: modeReadWrite) ; str. Format ( _T ( "%d" ) , bpnn-> mNumInputs) ; OutputFile. WriteString ( str) ; OutputFile. WriteString ( _T ( "\n" ) ) ; OutputFile. Close ( ) ; }