need help on readers and writes.......

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sir,

I have got a series of float values coming and i want to store these values
into a file in such a way that when one value is written in the file then it
goes to next line and writes other line.(like using of \n ; how can i do it.i
tried to use stream reader but it write file in UT8 type .i tried to used
binary reader but it is not working.

give me some alternative for it.

so that whatever the value come in my flaot variable is written in the file.

wating for your reply eagerly.

Regards

Naveen
 
Naveen said:
Sir,

I have got a series of float values coming and i want to store these values
into a file in such a way that when one value is written in the file then it
goes to next line and writes other line.(like using of \n ; how can i do it.i
tried to use stream reader but it write file in UT8 type .i tried to used
binary reader but it is not working.

give me some alternative for it.

so that whatever the value come in my flaot variable is written in the file.

wating for your reply eagerly.

Regards

Naveen

Try something like this?:

float[] f = new float[]{1,2,3,4,5,6,7,8,9,10};

System.IO.FileStream fs = new System.IO.FileStream(@"C:\output.txt",
System.IO.FileMode.Create);

for(int i=0; i < f.Length; i++)
{
byte[] b = new System.Text.ASCIIEncoding().GetBytes(f.ToString()
+ "\r\n");
fs.Write(b, 0, b.Length );
}

fs.Close();

You could also use the TextWriter, which has a NewLine() method.
 
First of all, if you want to write to a file you will need a writer, like
StreamWriter, second, StreamWriter has a method called WriteLine which takes
a float or a double parameter, and this I think will help you solve the
problem.

Tibi
 
Back
Top