a
This commit is contained in:
44
EastChanger/sfj4Class.cs
Normal file
44
EastChanger/sfj4Class.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user