string[0]="123,60";
string[1]="456,70";
string[2]="789,80";
string[3]="000,90";
string path="c:\\"
string filename="aaa"
想保存为c:\aaa.csv
求赐教!

解决方案 »

  1.   

    stringAAA[0]="123,60";
    stringAAA[1]="456,70";
    stringAAA[2]="789,80";
    stringAAA[3]="000,90";
    foreach(string s in stringAAA)
    {
       写入文件
    }求教这样用foreach是不是好点?
      

  2.   

    IO操作比较耗时,如果你写入的量不是很大,不足1M的话。我建议你使用StringBuilder对象进行拼接之后,在一次性写入IO文件中。
    代码如下:            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.AppendLine("第1行字符串");
                sb.AppendLine("第2行字符串");
                sb.AppendLine("第3行字符串");            using (System.IO.StreamWriter sw = new System.IO.StreamWriter("这里写filepath"))
                {
                    sw.Write(sb.ToString());
                }
      

  3.   

    File.WriteAllLines(Path.Combine(path,filename),string[]);