public string GetF(string path1,string path2)
{
try
{
WebClient wc = new WebClient();
wc.DownloadFile(@"E:\MyWeb\MyWeb2\Folder\" + path1, path2);
return "下载成功。。。";
}
catch
{
return "下载失败。。。";
}
public string GetFF(string path1, string path2)
{
try
{
WebRequest wr = WebRequest.Create(@"E:\MyWeb\MyWeb2\Folder\"+path1);
WebResponse pos = wr.GetResponse();
long totlebyte = pos.ContentLength;
Stream st = pos.GetResponseStream();
FileStream fs = new FileStream(path2,FileMode.OpenOrCreate,FileAccess.Write);
BinaryReader br = new BinaryReader(st);
StreamReader reader = new StreamReader(st);
byte[] bt = br.ReadBytes((int)st.Length);
fs.Write(bt,0,bt.Length);
st.Close();
fs.Close();
return "下载成功。。。";
}
catch
{
return "下载失败。。。";
}
}
|