Files
GateDge2023_ljy/EastChanger/sfj4Class.cs
PastSaid 5e2781182d a
2024-03-04 16:50:20 +08:00

45 lines
1.4 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace EastChanger
{
public static class sfj4Class
{
/// <summary>
/// 保存Txt到服务器商
/// </summary>
/// <param name="Data">接口调用数据</param>
/// <param name="path">Txt地址</param>
/// <param name="Result">接口返回数据</param>
public static void SaveTxt(string Data, string path, string Result)
{
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("\r\n");
sb.AppendLine("----------------------调用接口所用JSon----------------------");
sb.AppendLine(Data);
sb.AppendLine("\r\n");
sb.AppendLine("----------------------调用接口返回JSon----------------------");
sb.AppendLine(Result);
FileStream fs = new FileStream(path, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
fs.Position = fs.Length;
//开始写入         
sw.Write(sb.ToString());
//清空缓冲区       
sw.Flush();
//关闭流           
sw.Close();
fs.Close();
}
}
}