Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
try
{

string templateFile = "C:/Oneview_MAT/template.html";
string temp1 = File.ReadAllText(templateFile);
string outputFile = @"C:\Oneview_MAT\output.txt";
foreach (var i in val)
{
string eachkey = i.Key;
string eachval = i.Value;
if (temp1.Contains(eachkey))
{

string value = "output_"+eachkey ;
temp1 =temp1.Replace(value, eachval);
//Console.WriteLine(data);

}
}

string temp2 = File.WriteAllText(outputFile,temp1);
}

What I have tried:

I have tried reading html file, changing its content and then writing it to another file.I am getting error in this line- string temp2 = File.WriteAllText(outputFile,temp1);
Posted
Updated 13-Feb-18 18:35pm

1 solution

Try
C#
File.WriteAllText(outputFile,temp1);
 
Share this answer
 
Comments
Member 13677196 14-Feb-18 0:46am    
thanx..it worked..but how to store this ?
Patrice T 14-Feb-18 0:52am    
What do you want to store and where?
Member 13677196 14-Feb-18 1:05am    
i wanted to store after writing it...but thanx it worked ...i can check by opening it.thanx
Patrice T 14-Feb-18 3:19am    
but what you write is in temp1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900