public OpenFile ( string url ) : |
||
url | string | |
return |
public MemoryStream OpenFile(string url)
{
HttpWebRequest request = WebRequest.CreateHttp(url);
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponseAsync().Result)
using (Stream stream = resp.GetResponseStream())
{
MemoryStream ms = new MemoryStream();
CopyToStream(stream, ms, resp.ContentLength);
ms.Position = 0;
return ms;
}
}
private void DownloadIndexFile(string archive, int i) { try { string file = CASCConfig.CDNPath + "/data/" + archive.Substring(0, 2) + "/" + archive.Substring(2, 2) + "/" + archive + ".index"; string url = "http://" + CASCConfig.CDNHost + "/" + file; Stream stream = Cache.OpenFile(file, url, false); if (stream != null) { ParseIndex(stream, i); } else { using (var fs = downloader.OpenFile(url)) ParseIndex(fs, i); } } catch { throw new Exception("DownloadFile failed!"); } }