I've tried a lot of things as well as research and asking friends, but can't seem to write a second line without a "," replacing the line. All I'd to do is have a single line for each item read in a separate file.
Each read file has several of these items:
2/20/2014 7:33:10 AM
OPERATOR: jason
FILE: C:\ax14\Setups\000062363106RH.prt
UNITS: english
TEST RESULT: Pass
CHANNEL 1
TEST TYPE: VELOCITY
RESULT: Pass
UPPER LIMIT: 0.2260
LOWER LIMIT: 0.2220
MAX THICKNESS: 2.0110
MIN THICKNESS: 1.0110
MEASURED VELOCITY: 0.2225
MEASURED THICKNESS: 1.5215
Id like to have the date and velocity line in one line like this: "2/20/2014 7:33:10 AM, MEASURED VELOCITY: 0.2225"
and this is my problem
2/20/2014 7:33:10 AM,
,
,
,
,
,
,
,
,
,
,
,
, MEASURED VELOCITY: 0.2225
,
2/20/2014 7:52:28 AM,
,
,
,
,
,
,
,
,
,
,
,
, MEASURED VELOCITY: 0.2224
,
2/20/2014 7:58:46 AM,
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
namespace conApp
{
class Program
{
static void Main(string[] args)
{
String line;
try
{
using (StreamWriter sw = new StreamWriter("C:\\writetest\\writetest.txt"))
{
string mydirpath = "C:\\chat\\";
string[] txtFileList = Directory.GetFiles(mydirpath, "*.txt");
foreach (string txtName in txtFileList)
{
System.IO.StreamReader sr = new System.IO.StreamReader(txtName);
while ((line = sr.ReadLine()) != null)
{
if (!string.IsNullOrEmpty(line))
{
String spart = ".prt";
String sam = " AM";
String spm = " PM";
String sresult = "TEST RESULT: ";
String svelocity = "MEASURED VELOCITY: ";
String part = "";
String date = "";
String result = "";
String velocity = "";
// sw.WriteLine(line);
if (line.Contains(sam))
{
date = line;
}
if (line.Contains(spm))
{
date = line;
}
if (line.Contains(spart))
{
part = line;
}
if (line.Contains(sresult))
{
result = line;
}
if (line.Contains(svelocity))
{
velocity = line;
}
int I = 2;
string[] x = new string[I];
x[0] = date;
x[1] = velocity;
sw.WriteLine(x[0] + "," + x[1]);
}
}
}
}
}
catch
{
}
}
}
}