我正试图用c#(模拟 php功能——文档_get_contents)使用以下代码装载html的内容:
protected string file_get_contents(string fileName)
{
string sContents = string.Empty;
if (fileName.ToLower().IndexOf("http:") > -1)
{ // URL
System.Net.WebClient wc = new System.Net.WebClient();
byte[] response = wc.DownloadData(fileName);
sContents = System.Text.Encoding.ASCII.GetString(response);
} else {
// Regular Filename
System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
sContents = sr.ReadToEnd();
sr.Close();
}
return sContents;
}
However, this does not load the image in the html when rendering the content. But when use PHP file_get_content, it does load the image in the html when rendering the content.
没有人会有什么想法?