1.使用 DownloadFile 方式
WebClient wClient = new WebClient(); string url= "https://ss3.bdstatic.com/lPoZeXSm1A5BphGlnYG/skin/34.jpg"; string filename = System.IO.Path.GetFileName(url); wClient.DownloadFile(url, AppDomain.CurrentDomain.BaseDirectory+ filename);
2.文件流读取方式
WebClient wClient = new WebClient();
string url = "https://ss3.bdstatic.com/lPoZeXSm1A5BphGlnYG/skin/34.jpg";
string filename = Path.GetFileName(url);
Stream str = wClient.OpenRead(url);
StreamReader reader = new StreamReader(str);
byte[] mbyte = new byte[1000000];
int allmybyte = (int)mbyte.Length;
int startmbyte = 0;
while (allmybyte > 0)
{
int m = str.Read(mbyte, startmbyte, allmybyte);
if (m == 0)
break;
startmbyte += m;
allmybyte -= m;
}
reader.Dispose();
str.Dispose();
string path = AppDomain.CurrentDomain.BaseDirectory + filename;
FileStream fstr = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
fstr.Write(mbyte, 0, startmbyte);
fstr.Flush();
fstr.Close();
用户今天 : 3
用户昨天 : 15
用户最近的7天 : 69
用户最近的30天 : 283
用户这个月 : 229
用户这一年 : 4357
合计用户 : 6149
查看今天 : 7
查看昨天 : 15
查看最近7天 : 74
查看最近30天的 : 306
查看这个月 : 242
查看这一年 : 4829
合计查看 : 7484
谁是在线的 : 0