private static void downfile(string filepath)
{
int count = 0;
HttpWebRequest request;
HttpWebResponse response;
string name = filepath.Substring(filepath.IndexOf("interface/")+10);
string filename = Application.StartupPath + "\\" + name;
if (File.Exists(filename))
{
File.Delete(filename);
}
request = (HttpWebRequest)WebRequest.Create(filepath);
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
Console.WriteLine(" 获取状态: {0}", response.StatusDescription);
// Releases the resources of the response.
Stream responseStream = response.GetResponseStream();
//StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("ASCII"));
//Console.WriteLine(reader.ReadToEnd());
StreamReader sr = new StreamReader(responseStream, System.Text.Encoding.UTF8);
StreamWriter sw = new StreamWriter(filename, true, System.Text.Encoding.UTF8);
while (sr.Peek() >= 0)
{
count += 1;
string xinxi = sr.ReadLine();
Console.WriteLine(count.ToString()+". "+xinxi);
sw.WriteLine(xinxi);
//sw.Write(sr.ReadToEnd());
}
sw.Close();
sr.Close();
}