- Home /
Odd Error when creating a csv file
I'm working on creating a csv file. Now I have a strange error. Argument #3' cannot convert
System.Collections.Generic.List' expression to type `System.Text.Encoding'
OilChangeList = DatabaseManager.Instance.MakeOilChangeList ();
StringBuilder csvcontent = new StringBuilder();
csvcontent.AppendLine("Service Date, Location, Mileage, Labor, Oil Brand, Oil Price, Filter Brand, Filter Price");
for(int i=0; i <OilChangeList.Count; i++ )
{
csvcontent.AppendLine (OilChangeList[i].ServiceDate+", "+OilChangeList[i].Location+", "+OilChangeList[i].Mileage+"," +
" "+OilChangeList[i].Labor+", "+OilChangeList[i].OilBrand+", "+ OilChangeList[i].OilPrice+", "
+OilChangeList[i].FilterBrand+", "+OilChangeList[i].FilterPrice+", "+OilChangeList[i].OilFilterPurchaseLocation);
}
string csvpath= "D:\\xyz.csv";
File.AppendAllText(csvpath, csvcontent.ToString(), OilChangeList);
I've tried converting the list to a string at the creation of the list AND at the file append, also tried casting it as a string to no avail. What do I need to do to fix the error? Thanks!
Comment
Best Answer
Answer by ShadyProductions · Aug 05, 2017 at 06:57 PM
File.AppendAllText(csvpath, csvcontent.ToString(), OilChangeList);
The OilChangeList argument there is your problem.
It doesn't take list as argument , But an encoding like this:
File.AppendAllText(csvpath, csvcontent.ToString(), Encoding.UTF8);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
A node in a childnode? 1 Answer
Find the highest first value of a vector2 in a list? 2 Answers
how to control particles along a path? 0 Answers