StreamReader

Reply Forum
Forum postdaz07 @ 2008-09-19 20:32:04
ReplyReply to
Hi,

I need some help to write a programm that reads from a master file and an amend file. From this a new master file is written to with the amendments made to it. Here is my code so far:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Exercise2_3_2
{
class Program
{
static void Main(string[] args)
{
int stock_code, amend_code, quantity, sale_price,
buying_price, new_value;

char amend_type;


StreamReader sr = new StreamReader(File.Open("maststck.txt",
FileMode.Open));

StreamReader sr1 = new StreamReader(File.Open("amend.txt",
FileMode.Open));

StreamWriter sw = new StreamWriter(File.Open("newStock.txt",
FileMode.OpenOrCreate));

StreamWriter sw1 = new StreamWriter(File.Open("query.txt",
FileMode.OpenOrCreate));

// read line from maststck
string mastStr = sr.ReadLine();
// split the line up and store in array
string[] mastcopy;
mastcopy = mastStr.Split(',');
stock_code = Int32.Parse(mastcopy[0]);
quantity = Int32.Parse(mastcopy[1]);
buying_price = Int32.Parse(mastcopy[2]);
sale_price = Int32.Parse(mastcopy[3]);

// read line from amend text file
string amendStr = sr1.ReadLine();
// split the line up and store in array
string[] amendcopy;
amendcopy = amendStr.Split(',');
amend_code = Int32.Parse(amendcopy[0]);
amend_type = Char.Parse(amendcopy[1]);
new_value = Int32.Parse(amendcopy[2]);

while (amend_code != 9999 || stock_code != 9999)
{
if (amend_code == stock_code)
{




// pause for user input
Console.Write("Press ENTER to Continue");
Console.ReadLine();
}
}
}
I am now stuck-not sure how to read the next line!











© net-tutorials.com 2006 - 2012

MailContact net-tutorials.com