I have a problem. I wrote a program that will export results from it's search into a csv file.

The program gives the user an option to export only a certian amount of information. The information the program gathers is

First Name
Last Name
Phone Number
Location
Machine Type
Dell Tag

I have a check box for each bit of information the program can grab. I want the csv file to correctly place the information in the file based on what options the user selects.

I am adding the information which is generated from a listview control to an array list.

When I open the text file if I have the options First Name , Last Name and Location check boxes marked I get output in my text file like this for each line.

MachineName,FirstName,LastName, ,Location,,

You see there are blank csv values between lastname and after location. How can I get my program to generate the results correctly in the text file? I want it to look like this

MachineName,FirstName,LastName,Location

Keep in my the order of things in the output can change based on what check boxes the user selects. I have a boolean array setup in my function that stores the value of all the check boxes so the program will know if it needs to gather that data but, I can't figure out how to get the program to correctly output the data with out having blank values in spots if the user unchecks a box.