Hello I need some help, I'm trying to output something to a text file (.htm) which will then display the data that is being generated in the C# program..
Now the problem is, whenever I try to replace something, it doesn't work. Just replaces it with "System.Char[]"
Here is the code:
public static void WebPage(char[] text)
{
var theText = text;
string dir = Path.Combine(Directory.GetCurrentDirectory(), "index.htm");
if(!File.Exists(dir))
{
Console.WriteLine ("Cannot find the file");
return;
}
string webpage = getData (dir);
FileStream fstream = new FileStream(dir, System.IO.FileMode.Create);
StreamWriter sWriter = new StreamWriter(fstream);
string variable = "var text="; // This is the variable in "index.htm"
string replacement = variable + theText; // This is what I'm trying to replace it with
sWriter.Write(webpage.Replace(variable, replacement));
sWriter.Flush();
}
So basically, let's say that the program generated the line "Hello world, this is C#", it would then search through the index.htm file and find "var text=" and then replace it with "var text=Hello world, this is C#"
Any ideas please? :)