nextdoornextdoor
June 26th, 2007, 05:43 AM
The following is the coding
The problem of the coding is that it cant replace words that is held together like
eg
Auotname
Autonick
Autoname/Autonick
is there any problem in my while or if else?
can anyone help me plss
Thank you
+++++++++++++++++++++++++++++++++++++++++++++++++++++
StreamWriter^ writer = gcnew StreamWriter(filestream);
String^ str;
while ((str = din->ReadLine()) != nullptr)
{
if (str->IndexOf("Autoname") >= 0)
{
writer->WriteLine(str->Replace("Autoname",this->txtName->Text));
}
else if(str->IndexOf("Autonick") >= 0)
{
writer->WriteLine(str->Replace("Autonick",this->txtNick->Text));
}
else
{
writer->WriteLine(str);
}
} //end while
writer->Close();
The problem of the coding is that it cant replace words that is held together like
eg
Auotname
Autonick
Autoname/Autonick
is there any problem in my while or if else?
can anyone help me plss
Thank you
+++++++++++++++++++++++++++++++++++++++++++++++++++++
StreamWriter^ writer = gcnew StreamWriter(filestream);
String^ str;
while ((str = din->ReadLine()) != nullptr)
{
if (str->IndexOf("Autoname") >= 0)
{
writer->WriteLine(str->Replace("Autoname",this->txtName->Text));
}
else if(str->IndexOf("Autonick") >= 0)
{
writer->WriteLine(str->Replace("Autonick",this->txtNick->Text));
}
else
{
writer->WriteLine(str);
}
} //end while
writer->Close();