public static void WriteTXTFile(List<string> ExportList, string FilePath, string FileName)
{
#region Check Folder File path
if (!Directory.Exists(FilePath))
{
try
{
Directory.CreateDirectory(FilePath);
}
catch (Exception ex)
{
throw new Exception("can not create this filepath!");
}
}
if (FilePath.EndsWith(@"\"))
FilePath = FilePath + FileName;
else
FilePath = FilePath + @"\" + FileName;
if (File.Exists(FilePath))
{
File.Delete(FilePath);
}
#endregion
using (StreamWriter sw =
new StreamWriter(new FileStream(FilePath, FileMode.CreateNew), Encoding.UTF8))
{
for (int i = 0; i < ExportList.Count; i++)
sw.WriteLine(ExportList[i]);
}
}
数据导出到TXT文件
最新推荐文章于 2021-01-21 19:27:58 发布