Here is a small piece of code to introduce C# output strings into text files. The specific code is as follows:
public class WriteHelper { public static void WriteFile(object data) { try { string path = $@"D:\TokenLog\day{:yyyy-MM-dd}"; var filename = $"TokenLog{:yyyy-MM-dd HH}.txt"; if (!(path)) (path); TextWriter tw = new StreamWriter((path, filename), true); // true add data at the end of the file ($"----Generate time:{:yyyy-MM-dd HH:mm:ss}---------------------------------------------------------------------"); (()); (); } catch (Exception e) { } } } public static class Json { /// <summary> /// Convert to json string /// </summary> public static string ToJsonStr(this object obj) { return (obj, new JsonSerializerSettings { ReferenceLoopHandling = }); } }
Summarize
The above is the implementation code of C# output strings into text files introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!