用CStdioFile 可以实现 CStdioFile file; if (!file.Open("myDoc.txt", CFile::modeReadWrite)) return FALSE; CString strRead, strText; while (file.ReadString(strRead)) { if (strRead.Left(4) == "ABC=") strText = strReplace; else strText = strRead; } file.Close(); // create a temple file to replace the text file CStdioFile tempFile; if (!tempFile.Open(file.GetFileTitle()+".tmp", CFile::modeCreate | CFile::modeReadWrite)) return FALSE; tempFile.WriteString(strText); tempFile.Close();// remove the text file, and rename the temple file with your old text file name CFile::Remove("myDoc.txt"); CFile::Rename(file.GetFileTitle()+".tmp", "myDoc.txt");
ls_arg=trim(sle_name.text) //记着用trim()阿。
SELECT *
FROM tab
WHERE name =:ls_arg;
这样应该就ok了。
http://community.csdn.net/Expert/topic/3855/3855028.xml?temp=.953869
CStdioFile file;
if (!file.Open("myDoc.txt", CFile::modeReadWrite))
return FALSE;
CString strRead, strText;
while (file.ReadString(strRead))
{
if (strRead.Left(4) == "ABC=")
strText = strReplace;
else
strText = strRead;
}
file.Close();
// create a temple file to replace the text file
CStdioFile tempFile;
if (!tempFile.Open(file.GetFileTitle()+".tmp", CFile::modeCreate | CFile::modeReadWrite))
return FALSE;
tempFile.WriteString(strText);
tempFile.Close();// remove the text file, and rename the temple file with your old text file name
CFile::Remove("myDoc.txt");
CFile::Rename(file.GetFileTitle()+".tmp", "myDoc.txt");
读一行 --> 改一行 --> 写一行
{
CStdioFile file;
CString path;
path="c:\\windows\\";
if (!file.Open("read.ini", CFile::modeReadWrite))
return FALSE;
CString strRead, strText,strReplace;
strReplace="XR_TSL_INIT="+str;
while (file.ReadString(strRead))
{
if (strRead.Left(12) == "XR_TSL_INIT=")
strText += strReplace+"\r\n";
else
strText += strRead+"\r\n";
}
file.Close();
CFile::Remove(path+"wrun.ini");
// create a temple file to replace the text file
CStdioFile tempFile;
if (!tempFile.Open(path+"wrun.ini", CFile::modeCreate | CFile::modeReadWrite))
return FALSE;
tempFile.WriteString(strText);
tempFile.Close();
return TRUE;
}