如何读取http text file?
http://localhost/test/myfile.txt
如何读取這個text file?
[解决办法]
stirng path = HttpContext.Current.Server.MapPath(@"~\test\myfile.txt")
StreamReader sr = new StreamReader(path,System.Text.Encoding.GetEncoding("GB2312"));
sline = sr.ReadToEnd();
sr.Close();
[解决办法]
using System.Net; WebClient wc = new WebClient(); string webstr = ""; try { webstr = System.Text.Encoding.Default.GetString(wc.DownloadData(url)); } catch (Exception ee) { MessageBox.Show("错误!" + ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); RemoveStatus(); return; }