Q:

How to Ignore a field and set the ignored field as a global variable within the function? 

I have this code to combine 2 different csv files.   
try
{
    var jobStartLine = File. OpenText(PackAuftrag).ReadLine();
    var comparisonField = jobStartLine. Split(';')[4];

    foreach (var line in File. ReadAllLines(BoxData))
    {
        var fields = line. Split(new char[] {';'}, 2);

        if (comparisonField == fields[0])
        {
            File. WriteAllLines(JobStart, 
                               new string[] {jobStartLine + ";" + fields[1]});
            break;
        }
    }
}

My BoxData = data1;data2;data3;data4;data5
At the moment data2 to data5 is getting in JobStart file.  
Data5 shouldn't be included inside JobStart file.  
I want to set data5 as a global variable. 
How can I do this, I just cannot figure this out, need help.  
This can help understanding my problem: How to compare 2 .csv files and create a new .csv containing parts from both csv files?  

A:

Here is how I sovled my problem:
  if (File. Exists(JobStart))
        {
            File. Delete(JobStart);
        }

        try
        {
            var jobStartLine = File. OpenText(PackAuftrag).ReadLine();
            var comparisonField = jobStartLine. Split(';')[4];

         foreach (var line in File. ReadAllLines(BoxData))
            {
                var fields = line. Split(new char[] { ';' }, 2);

                if (comparisonField == fields[0])
                {

                    string string2write = "";
                    string2write += JobName + ',';
                    string2write += jobStartLine. Split(';')[0] + ',';
                    string2write += jobStartLine. Split(';')[1] + ',';
                    string2write += jobStartLine. Split(';')[2] + ',';
                    string2write += jobStartLine. Split(';')[3] + ',';
                    string2write += jobStartLine. Split(';')[5] + ',';
                    string2write += line. Split(';')[1] + ',';
                    string2write += line. Split(';')[2] + ',';

                    string2write += line. Split(';')[3] + ',';
                    string2write += line. Split(';')[4] + ',';
                    string2write += line. Split(';')[5] + ',';
                    string2write += line. Split(';')[6];
                    PrinterSelected = line. Split(';')[7];

                    FileStream fst = new FileStream(JobStart, FileMode. Create, FileAccess. Write);
                    StreamWriter stw = new StreamWriter(fst, Encoding. Default);
                    stw. Write(string2write);
                    stw. Dispose();
                    stw. Close();

//                        File. WriteAllLines(JobStart, new string[] { jobStartLine + ";" + fields[1]});

                    break;
                }

