public virtual bool DownloadFile(string url, string filename, Action <ERRORLEVEL> _OnCompleted) { DownloderAsync.__DebugOutput("AsyncDownloder.DownloadFile : " + url); this.ErrorString = string.Empty; this.ErrorLevel = ERRORLEVEL.SUCCESS; this.OnCompletedFile = _OnCompleted; this.client = new WebClient(); this.client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.OnDownloadFileProgressChanged); this.client.DownloadFileCompleted += new AsyncCompletedEventHandler(this.OnCompleted_File); this.client.DownloadFileAsync(new Uri(url), filename); return(true); }
public virtual bool DownloadString(string url, Action <ERRORLEVEL, string> _OnCompleted) { this.isNeedRetry = true; this.OnCompletedString = _OnCompleted; this.ErrorString = string.Empty; this.ErrorLevel = ERRORLEVEL.SUCCESS; this.client = new WebClient(); this.client.Encoding = Encoding.UTF8; this.client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(this.OnCompleted_String); this.client.DownloadStringAsync(new Uri(url)); DownloderAsync.__DebugOutput("AsyncDownloder.DownloadString : " + url); return(true); }
public override bool DownloadFile(string url, string filename, Action <ERRORLEVEL> _OnCompleted) { DownloderAsync.__DebugOutput("AsyncDownloder.DownloadFile : " + url); base.ErrorString = string.Empty; base.ErrorLevel = ERRORLEVEL.SUCCESS; this.OnCompletedFile = _OnCompleted; url = url.Replace("//", "/"); url = url.Replace("http:/", "http://"); this.behaviour = NPatchLauncherBehaviour.Owner.GetComponent <NPatchDownloderAsyncBehaviour>(); if (this.behaviour == null) { this.behaviour = NPatchLauncherBehaviour.Owner.AddComponent <NPatchDownloderAsyncBehaviour>(); } this.behaviour.StartCoroutine(this.behaviour.DownloadFileRoutine(url, filename, this.OnCompletedFile, new Action(this.OnPrograss_File))); return(true); }
public static void __DebugOutput(string msg) { DownloderAsync.__DebugOutput(msg, null); }