0

I can't seem to find a way to write an entire HTML file via c#, I can only find something to write it line by line, but is there a way to add it all at once? Sorry for my bad English :(.
This is what I have at the moment:

string path = @"c:\MyTest.html"; // This text is added only once to the file. if (!File.Exists(path)) { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(@"<script type="text/javascript/">"); } } 

1 Answer 1

2

You can write a string to a file using System.IO.File.WriteAllText.

Sign up to request clarification or add additional context in comments.

2 Comments

But how can I put javascript and quote signs in a string? It doesn't want to do it with quotes and other signs.
This seems to be a different question from writing to a file. Consider posting it as a new question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.