.NET File.WriteAllLines leaves empty line at the end of file

前端 未结 9 1165
情歌与酒
情歌与酒 2020-12-17 17:58

When I\'m saving content of the String[] array with System.IO.File.WriteAllLines, at the end of a file is always left a blank line. For example:

System.IO.Fi         


        
9条回答
  •  忘掉有多难
    2020-12-17 18:36

    i did the same thing just adding a line :3 , hope that helps someone

        for(int i = 0; i < Length; i++)
        {
            line = getLocation(i).X.ToString("0.0", nfi) + ',' + getLocation(i).Y.ToString("0.000", nfi) + ',' + getColorRaw(i).R.ToString("0.000", nfi) + ',' + getColorRaw(i).G.ToString("0.000", nfi) + ',' + getColorRaw(i).B.ToString("0.000", nfi);
            writer.Write(line);
            if( i < Length - 1) writer.Write("\n");
    

提交回复
热议问题