C# 匯出 CSV檔案

如標題

List<自訂類別CSV>  group = new  List<自訂類別CSV> ();
                    //產生一個CSV資料
                    自訂類別CSV m = new 自訂類別CSV();
                    m.alonso01 = "123";
                   m.alonso02 = "456";
                    group.Add(m);
            
				
				    //存檔到指定目錄       
                string filename = "";
                   filename = @"C:\\檔案名稱.csv";
             
                //產csv檔直接儲存到server
                StringBuilder sb = new StringBuilder();
                Type t = typeof(自訂類別CSV);
                PropertyInfo[] propInfos = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);

                foreach (var item2 in group)
                {
                    sb.AppendLine(string.Join(",", propInfos.Select(i => i.GetValue(item2))));
                }

				//此段為直接寫入檔案
                File.WriteAllText(filename, sb.ToString(), Encoding.Default);