c# 导出text 文本文件
/// <summary> /// 机构代码信息 /// </summary> public static void ExportT_XQJBQK_SLGAJGDM(DataTable dt,string name) { if(dt.Rows.Count>0) { string filepath = @"E:\ContDB\"+name+ @"\机构代码.txt"; StreamWriter f = new StreamWriter(filepath, false); f.WriteLine("机构编码,机构名称,机构简称,机构缩写,经度,纬度"); foreach (DataRow d in dt.Rows) { f.WriteLine(d["JGBM"]+","+d["JGMC"]+","+d["JGJC"]+","+d["JGSX"]+","+d["X"]+","+d["Y"]); } f.Close(); Console.WriteLine("机构代码保存成功!"); } }