Hi all,
started c# last time, but now i got a Problem...i Need a snippet 2 understand how to to it.
Problem:
private void button1_Click(object sender, EventArgs e)
{
using (StreamWriter writer = new StreamWriter(@"C:/WEBUPLOAD/UPLOAD/Output.csv", true))
{
using (StreamReader reader = new StreamReader(@"C:/input.csv", System.Text.Encoding.Default))
{
string line;
while ((line = reader.ReadLine()) != null)
{
string[] items = line.Replace("\"", "").Trim().Split(';');
if (items.Length != 4) continue;
int i1, i2;
bool b1 = int.TryParse(items[2], out i1);
bool b2 = int.TryParse(items[3], out i2);
items[2] = Math.Max(0, i1 -i2).ToString();
line = String.Join("~", items, 0, 3);
writer.WriteLine(line);
}
I wanna rewrite the Code above, but dont now how to do that with two files.
I get a 1 File that looks like that:
"";"";0
" 09000";"Catalog 1";10148
" 09001";"Catalog 2";20
" 09002";"Catalog 3";166
I get a 2 File that looks like that:
" 09000";476
" 09003";10
" 09005";5
What to do?
the Output file must look like that:
09000~Catalog 1~9672
09001~Catalog 2~10
09002~Catalog 3~161
I need to substract Field 3 from File1, with Field 2 from File 2 and get a Output File like above.