c.NET writes txt files for small examples

  • 2020-06-12 08:47:27
  • OfStack

Before you do that, you can decide 1 if the file you want to exist exists, if it does, save it, if it doesn't

Write file code:
StreamWriter wr = new StreamWriter(Server.MapPath("saveFile.txt"),false,System.Text.Encoding.Default);
try
{
wr.Write(" here is the content ");
wr.Close();
Response.Write(" < script > alert(' file writes successfully '); < /script > ");
}
catch
{
Response.Write(" < script > alert(' file write failed '); < /script > ");
}

This code needs to be referenced: using ES45en.IO;

Once you see this code, you can think of the code that generates the static file, which is also used to save the contents to an HTML file, without further discussion.


Related articles: