I am returning an html string as return value of a function. The return string is somewhat long (but nothing compared to limit of string datatype). But the returned string is getting truncated.
I tried to convert it to StringBuilder with no benefit.
P.S. My class is inside a .dll and I am trying to access it from outside,
What’s wrong and what should I do?
I am consuming here:
string st = asso.getHtmlReport();
FileStream fs = File.OpenWrite("file.html");
StreamWriter sw = new StreamWriter(fs);
sw.Write(st);
This is the string
public string getHtmlReport()
{
string html = "<html><head><title>Association</title></head><body>" +
"<table >" +
"<tr align=\"left\">" +
"<th>t</th>" +
"<th>" + name1 + "</th>" +
"<th>Avg rise</th>" +
"<th>" + name2 + "</th>" +
"<th>Avg rise</th>" +
"<th>Difference</th>" +
"<th>Direction</th>" +
"</tr>" +
"<tr>"+
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top\">" +
seriesPrint(t) +
"</td>" +
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top\">" +
seriesPrint(series1) +
"</td>" +
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top\">" +
seriesPrint(avg1) +
"</td>" +
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top>" +
seriesPrint(series2) +
"</td>" +
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top\">" +
seriesPrint(avg2) +
"</td>" +
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top\">" +
seriesPrint(diff) +
"</td>" +
"<td style=\"padding-left:10px;padding-right:20px;\" valign=\"top\">" +
seriesPrint(dir) +
"</td>" +
"</tr>"+ "</table>" +
"<div style=\"padding:10px; position:absolute; right:0px; top:0px; width:300px; border:this solid black; background-color:Black; color:White;\">" +
"<span style=\" font-weight:bolder; font-size: 2em; color: White;\">Results</span><br />" +
"<span style=\" font-weight:bolder; font-size: 1em; color: White;\">Total records : " + series1.Length + "</span><br />" +
"<span style=\" font-weight:bolder; font-size: 1em; color: White;\">Average error : " + avgError() + "</span><br />" +
"<span style=\" font-weight:bolder; font-size: 1em; color: White;\">Together : " + support() + "</span><br />" +
"<span style=\" font-weight:bolder; font-size: 1em; color: White;\">Opposite : " + (series1.Length - support()) + "</span><br />" +
"</div>" +
"</body></html>";
return html;
}
You need to flush your stream after you write it.