新建文件对话框,选择路径,新建并写入文件

来源:互联网 发布:s. 忒修斯之船 知乎 编辑:程序博客网 时间:2024/06/10 09:11

//新建文件对话框,选择路径,新建并写入文件 
 CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
  "All Files(*.TXT)|*.TXT||",AfxGetMainWnd());
 CString strPath,strText="";
 char write[1000000];
 if(dlg.DoModal()==IDOK)
 {
  strPath=dlg.GetPathName();
  if(strPath.Right(4)!=".txt")
   strPath+=".txt";
  CFile file(_T(strPath),CFile::modeCreate|CFile::modeWrite);
  strcpy(write,"set_value ka_r [ expr ");
  strcat(write,ka_r);
  strcat(write, " ] ; #  (I) UL: BS recv. ante Num/nset_value ka_s [ expr ");
  //strcat(write,"set_value ka_r [ expr "); 
  //strcat(write,c);
  //strcat(write,"]/nset_value noiseonoff [ expr 1.0  ] ; #  (R)");
  file.Write(write,strlen(write));
  file.Close(); 
 }