I guess first lets take a small look to CSV files..
What is csv file ? Actually its self-explained (Comma Seperated Values) but simply A CSV file is a file which carries/stores the different values with seperation of a Comma (something like ',' or ';' or other else )
So when you want to create a csv file you can simply iterate your values and seperate it with some chars which you decide..
Just be careful that your delimiters (the characters which you decide to use to seperate different values from others) shouldn't be in your values..
Say you have this poem to store and you want to seperate from poem-rows with the delimiter "," :
When evening comes
Mails singing misses,
But Zagreb(Croatian) Radio the Lili Marleen Song
....
We, All Human-kind sweared :
we believed on Freedom,
We, sweared for the sake of Freedom!
.....
[ Attila ILHAN ]
what will happen? you got unexpected results cause the poem has your delimiter in its body..
with a pseudo :
1-) decide your delimiter(s) as data bodies don't have
2-) get your data as string
3-) Append with your delimiter to your csv file
EDIT - After op comments to me, changes his question-body with useful knowledges from other commentators' comments..
PSEUDO :
string delimiter = "##";
string Path = yourCSVFilePathToSave;
bool append = true;
string HexadecimalFormat = "X";
Encoding enc = Encoding.UTF-8;
int bufferSize = 4096;
int[] intArray = {1,2,3,4,5,6,7,8,9};
using ( var writer = new StreamWriter(Path, append, enc, bufferSize))
{
foreach ( int i in intArray)
{
writer.Write (HexadecimalFormat, i);
writer.Write (HexadecimalFormat, delimiter);
}
}
PSEUDO To Read :
List<string> list = new List<string>();
using (var reader = new StreamReader(Path, enc))
{
list.AddRange(reader.ReadLine().Split(new char[] { '#', '#' }, StringSplitOptions.RemoveEmptyEntries).ToList());
}