BOOL MyAppWindow :: SaveFile( void ) { XFile savefile; XString s; mle->GetText( &s ); /* now open the file, create a new one if the given filename is not existing, otherwise overwrite */ /* it. open the file for write-access, dont allow any other programm to use the file while it is open*/ if( savefile.Open( path, XFILE_CREATE_IF_NEW | XFILE_REPLACE_EXISTING, XFILE_SHARE_DENYNONE | XFILE_WRITEONLY, s.GetLength()) == 0) { /* set the file-cursor to the beginning of the file */ savefile.Seek( 0, FILE_BEGIN); /*save the string */ savefile.Write ( (char*) s, s.GetLength()); /* close the file */ savefile.Close(); saved = TRUE; return TRUE; } else { XMessageBox( "could not open file", "error", MB_OK| MB_ERROR); return FALSE; } }