Thanks squidge! But, i am using ReadWrite mode in QFile, which is not rewriting the whole file rather it is writing the desired content at the end of file. Something like this...
Input file:
bb1
bb2
bb3
o/p getting:
bb1
bb2
bb3
bb1
$$bb2
bb3
desired o/p:
only:
bb1
$$bb2
bb3
QFile file_bl1
("E:\\SMS\\dSenderBlackList.txt");
file_bl1.reset();
bl_line1 = bl_in1.readLine();
while(!bl_line1.isNull())
{
if(str==bl_line1)
{
bl_in1<<"$$"<<str<<"\n";
}
else
{
bl_in1<<bl_line1<<"\n";
}
bl_line1 = bl_in1.readLine();
}
QFile file_bl1("E:\\SMS\\dSenderBlackList.txt");
file_bl1.open(QIODevice::ReadWrite | QIODevice::Text);
file_bl1.reset();
QTextStream bl_in1(&file_bl1);
QString bl_line1;
bl_line1 = bl_in1.readLine();
while(!bl_line1.isNull())
{
if(str==bl_line1)
{
bl_in1<<"$$"<<str<<"\n";
}
else
{
bl_in1<<bl_line1<<"\n";
}
bl_line1 = bl_in1.readLine();
}
To copy to clipboard, switch view to plain text mode
I am trying , but it would be good if someone can help me in figuring out how to perform aforementioned. Thanks.
Added after 29 minutes:
Thanks Squidge!! PROBLEM is solved. Just took a different pointer for writing.
Bookmarks