This article describes the method of writing text file contents in C#. Share it for your reference. The details are as follows:
private void write_txt(string str1, string str2, string str3) { currentTime = ; string strYMD = ("d"); string FILE_NAME = "MyFileSend" + strYMD + ".txt"; // Create a different file name according to date every day StreamWriter sr; if ((FILE_NAME)) //If the file exists, create an object { sr = (FILE_NAME); } else //If the file does not exist, create an object { sr = (FILE_NAME); } (str1 + " " + str2 + " " + ("yyyy-mm-dd hh:mm:ss") + " " + str3 + "\r\n"); //Write the passed string plus time to a line of text file (); }
I hope this article will be helpful to everyone's C# programming.