prog77 0 Newbie Poster

The code .. modifies a files from line 56 to 66 if it finds a 0 and if it finds a 1 it doesnt do any change in file . I m reading 0 and 1 from ms acess database file and for each 0 or 1 in a particular row associated prog1.in , prog2.in ...so on will be there as many as num of rows. the problem i have is the file type initially is prog.in which i normally open in textpad . When i do this prog and modify files which has row value 0 i get output required properly but the file format gets modifies because of which my actions to be perfomed later are getting effected . I want the modified also in same format . The prog.in file is something like.. parameters in a row and values in other rows.. one after other !!
Please someone help me with how to keep same formatting as before modifyin the file

private void button1_Click(object sender, EventArgs e)

{

{

n = int.Parse(textBox1.Text);

for (q = 1; q <= n; q++)

{

w = int.Parse(ds.Tables[0].Rows.ItemArray[1].ToString());

s++;

if (w == 0)

{

string myFile = "";

string fileName = "c:rocky\\program" + q + ".in";

//StringBuilder = new StringBuilder(fileName);

StreamReader srRead = File.OpenText(fileName);

srRead.BaseStream.Seek(0, SeekOrigin.Current);

while (srRead.Peek() > -1)

{

myFile = myFile + srRead.ReadLine() + "\n";

}

srRead.Close();

char[] splitChar = { '\n' };

string[] fileArray;

fileArray = myFile.Split(splitChar);

myFile = "";

for (int x = 0; x < fileArray.Length; x++)

{

if (x <= 56 || x >= 66)

{

myFile = myFile + fileArray[x].ToString();

}

}

//Delete the file

File.Delete(fileName);

//Write the new file

FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate,

FileAccess.Write);

StreamWriter swFromFileTrueUTF8Buffer = new StreamWriter(fs,

System.Text.Encoding.UTF8);

swFromFileTrueUTF8Buffer.Write(myFile);

swFromFileTrueUTF8Buffer.Close();

fs.Close();

}

else

{

}

}

}

}