N
nasirmajor
Dear all i have the following code for writing to the existing file.
===========================
void AppendToFileEng()
{
SqlDataReader gr = null;
string engpath2="";
gr = db.GetReader("Select * from tbl_SubCat2 Where
SId2=" + SId2 + "");
if (gr.Read())
{
engpath2 = gr[5].ToString();
}
string strfname = Server.MapPath(@"..\" + engpath2);
Response.Write(strfname);
StreamWriter fp = File.AppendText(strfname);
//what should be done here or else where
fp.WriteLine(txtengfile.Text);
fp.Close();
fp.Dispose();
}
==================================
well this file do write to the existing file but it does not edit the
file
e.g if the followig line is in the text file
------> this is wrong file
and if after i write to file this line and delete above line
------> this is ok file
then previous line also remains there and new line is added as well i.e
output comes like this
------> this is wrong file
------> this is ok file
i want the line "this is wrong file" to be removed and just "this is ok
file" line.
Thanks in advance.
===========================
void AppendToFileEng()
{
SqlDataReader gr = null;
string engpath2="";
gr = db.GetReader("Select * from tbl_SubCat2 Where
SId2=" + SId2 + "");
if (gr.Read())
{
engpath2 = gr[5].ToString();
}
string strfname = Server.MapPath(@"..\" + engpath2);
Response.Write(strfname);
StreamWriter fp = File.AppendText(strfname);
//what should be done here or else where
fp.WriteLine(txtengfile.Text);
fp.Close();
fp.Dispose();
}
==================================
well this file do write to the existing file but it does not edit the
file
e.g if the followig line is in the text file
------> this is wrong file
and if after i write to file this line and delete above line
------> this is ok file
then previous line also remains there and new line is added as well i.e
output comes like this
------> this is wrong file
------> this is ok file
i want the line "this is wrong file" to be removed and just "this is ok
file" line.
Thanks in advance.