Can write to csv file but not append

前端 未结 2 1082
夕颜
夕颜 2021-01-27 06:58
string pathDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        string filePath = pathDesktop + \"\\\\mycsvfile.csv\";
        string delimter         


        
2条回答
  •  猫巷女王i
    2021-01-27 07:42

    Can you please try with StreamWriter class?

    If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.

    Instead using TextWriter writer = File.CreateText(filePath) try to use

    TextWriter writer = new StreamWriter(filePath, true);

    If you pass true in constructor it should append text to file.

提交回复
热议问题