void CXunJianDlg::OnBnClickedOpenfile() { // TODO: 在此添加控件通知处理程序代码 CStdioFile listfile; if( opened == true || listfile.Open(xj_ipListFileName,CFile::modeRead,0) == false) { //listfile.Close(); m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); CFileDialog FileDlg(true, _T("txt"),NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, "文本文件(*.TXT)|*.TXT|All Files(*.*)|*.*||"); if( FileDlg.DoModal() == IDOK ) { xj_ipListFileName = FileDlg.GetFileName(); listfile.Open(xj_ipListFileName,CFile::modeRead,0); } else return; } xj_ipListFileName = listfile.GetFileName();//FileDlg.GetFileName(); xj_FilePath = listfile.GetFilePath();//FileDlg.GetPathName(); xj_FilePath.Replace(xj_ipListFileName,""); xj_FilePath.Replace("\\","\\\\"); pList= (CListBox *)GetDlgItem(IDC_HOSTLIST); pList->ResetContent(); CString str; while(listfile.ReadString(str)) { if(str.Find("\'") == -1) //空行不加入 ,有 '符号不加入,相当于注释掉此行 { str.Replace(" ",""); //去除所有空格 pList->AddString(str); } } opened = true; listfile.Close(); UpdateData(false); }
CFieldValuePair::DumpARX(CARSConnection &arsConnect, CString Form, CStdioFile &File, CString &strAttachDir, unsigned int *p_uiAttachNum, CEntryId &EntryId, CString &strBuffer) { // Insert a space before the value // File.Write(" ", 1); strBuffer += " "; CString cleanValue(Value); // dump the value to the file switch(uiType) { case AR_DATA_TYPE_NULL: //File.Write("\"\"", 2); strBuffer += "\"\""; break; // basically an value exported via this case will not have any double // quotes exported case AR_DATA_TYPE_INTEGER: case AR_DATA_TYPE_REAL: case AR_DATA_TYPE_ENUM: case AR_DATA_TYPE_TIME: case AR_DATA_TYPE_DECIMAL: //File.Write(LPCSTR(Value), Value.GetLength()); // write the value strBuffer += Value; break; // any value exported via this case will have double quotes // inserted before and after the Value. case AR_DATA_TYPE_CHAR: case AR_DATA_TYPE_DIARY: case AR_DATA_TYPE_CURRENCY: // treat currency like a char because we need to double quotes cleanValue.Replace("\"", "\\\""); // insert a \ before each double quote cleanValue.Replace("\n", "\\r\\n"); // replace carriage returns with \r\n text //File.Write("\"", 1); // write double quote before value strBuffer += "\""; //File.Write(LPCSTR(cleanValue), cleanValue.GetLength()); // write the text value strBuffer += cleanValue; //File.Write("\"", 1); // write double quote after value strBuffer += "\""; break; case AR_DATA_TYPE_ATTACH: CString strExt; // working extenstion of the attachment CString strFile; // working file name with no extension CString strAttachNum; // working string for attachment number CString strFinishedAttach; // working completed attachment name to use when calling GetEntryBLOB() CString strFilePath; // the full path the the filename for saving the BLOB file // Save the file extension strExt = Value; strExt.MakeReverse(); strExt = strExt.Left(4); strExt.MakeReverse(); // Save the file name with out extenstion strFile = Value.Left(Value.GetLength() - 4); // convert the Attachment number to a string and increment it strAttachNum.Format("%d", *p_uiAttachNum); *p_uiAttachNum = *p_uiAttachNum + 1; // build the completed attachment name to save // strBuffer += "\"" + strAttachDir + "\\" + strFile + "_" + \ // strAttachNum + strExt + "\""; strFinishedAttach = strAttachDir + "\\" + strFile + "_" + strAttachNum + strExt; strBuffer += "\"" + strFinishedAttach + "\""; // Lastly, save the attachment file BLOB // This function call needs the full path\filename to save the BLOB // this should be specified in strAttachFileName strFilePath = File.GetFilePath(); strFilePath.Replace(File.GetFileName(), LPCSTR(strFinishedAttach)); // replace the filename with the relative attachment name DumpAttachment(arsConnect, Form, EntryId, uiFieldId, strFilePath); break; } // end switch }