I know this is probably a very simple problem, with most likely a very simple solution, but I have been banging my head against a wall for a while now. For some reason this code is not writing to the text files I would like it to and I cannot figure out why
There's not much to it, but I can't figure out where I am going wrong. It builds successfully, but nothing gets written.
Thanks
C#:
namespace Application1
{
class Program
{
static void Main(string[] args)
{
var input = @"C:/Users/cswenson/Desktop/TestProgram/test.txt";
var outputp = @"C:/Users/cswenson/Desktop/TestProgram/preout.txt";
var outputm1 = @"C:/Users/cswenson/Desktop/TestProgram/match1.txt";
var outputm2 = @"C:/Users/cswenson/Desktop/TestProgram/match2.txt";
using (var sr = new StringReader(input))
using (var psw = new StreamWriter(outputp, true))
using (var o1sw = new StreamWriter(outputm1, true))
using (var o2sw = new StreamWriter(outputm2, true))
{
foreach (string line in File.ReadLines(input))
{
string preout = line.Substring(1, 8) + " " + line.Substring(374, 329) + " " + line.Substring(4937, 639);
psw.WriteLine(preout);
string match1 = line.Substring(1, 8) + " " + line.Substring(9, 365) + " " + line.Substring(703, 1786);
o1sw.WriteLine(match1);
string match2 = line.Substring(1, 8) + " " + line.Substring(2489, 2448);
o2sw.WriteLine(match2);
}
}
}
}
}
Thanks
Last edited by a moderator: