S3RD4R

Hi !

I am getting 10 different values from my function and want to save these values in a .txt file. Each value must be in the same row.e.g;

row1 row2

value1 value1

value2 ............

any opinion sample code will be usefull.

Thanks for all.



Re: Visual C# Express Edition Creating Text files

jrboddie

Your example is a little confusing to me.

Do you mean you want the file to contain 10 lines with the same value twice on eact line like this:

value1 value1

value2 value2

value3 value3

value4 value4

.

.

value10 value10





Re: Visual C# Express Edition Creating Text files

S3RD4R

I mean get ten different values from a function. want to read this function dynamically and write these values in the same row.

array[10];

&array=function(......);

call this function in an infinite loop. then in a text file i write the values

row1 row2 row3 row 4 ...........................

array[0] array[1] array[2] array[3] ..........................

array[0] array[1] .................................................................

i hope it is clear





Re: Visual C# Express Edition Creating Text files

nobugz

Try something like this:

using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\temp\test.txt")) {
for (int ix = 0; ix < 10; ++ix) sw.Write("Column{0}\t", ix + 1);
sw.WriteLine();
for (; ; ) {
string[] arr = GetTenValues();
if (arr == null) break;
foreach (string value in arr) sw.Write("{0}\t", value);
sw.WriteLine();
}
}