My code has a split function that should split the text file of numbers.
I've run this in previous programs as it is here and it worked, but now it
wont work for some reason and returns System_String[]. I don't see a
difference in the previous code and what I have now. Can anyone find where I
went wrong? Thanks a bunch!
//Open new stream reader and writer to read in file
//And write to a new file.
StreamWriter swa=new StreamWriter("c:\\afinal.txt");
StreamReader sra=new StreamReader("c:\\Acolumn.txt");
string aLine="";
double AField;
//Create and initialize arraylist
ArrayList aColumn = new ArrayList ();
while (aLine != null)
{
//Read each line in and add to previous
//As long as the line contains a string of characters.
aLine=sra.ReadLine();
if (aLine != null)
aColumn.Add(aLine);
}
sra.Close();
//Splits the text file as space delimited, begins new line there
foreach (string aOutput in aColumn)
{
string[] aFields = aOutput.Split(new char[] {' '});
{
foreach (string aField in aFields)
{
if (aField.Length !=0)
{
//Convert each line/item of array to double data type
AField = System.Convert.ToDouble (aField);
//Multiply each decimal value by constant
AField = AField*2;
//Write new value to console and new text file.
Console.Write (">"+ AField +"<");
swa.WriteLine(AField);
}
}
}
}
Console.Read();
swa.Flush();
swa.Close();