How to replace a particular text in a file located at any place..?
hey can any1 tel me how to replace the text in a file which is located at any place......?
and can can i edit any .ini file....below is my code....
Code:
QFile file("E:/qtpro/ABC/abc.ini");
file.reset();
while (!file.atEnd())
{
str = fl.readLine();
if (str == ";extension=abc_123.dll")
{
fl<<"extension=abc_123.dll"<<str<<"\n";
}
//else
//{
//fl<<str<<"\n";
//}
str = file.readLine();
}
Re: How to replace a particular text in a file located at any place..?
If you want to mange settings in an ini file, check out QSettings - saves you the trouble of manually worrying about reading and writing in to a file - you just set the settings by they name.
Re: How to replace a particular text in a file located at any place..?
can u tel me, how can i perform the same task for a text file?? is my code correct for it.?
Re: How to replace a particular text in a file located at any place..?
you need to read the file until where place is where you want to edit it, read the rest of the file, but save the data in memory, seek() back to the place where you want to edit, append your new string, append the rest of the file which you hold in memory, close the file.