public bool DownloadFile(URLWithISLocal url, string localPath) { NormalConnects.Connection_Base connection; if (url.IsLocal) { connection = new NormalConnects.LocalConnect(url.URL, localPath); } else { connection = new NormalConnects.HttpConnect(url.URL, localPath, string.Empty); } bool downloadFinished = false; bool downloadResult = false; connection.DownloadResource(delegate(bool result, object str) { downloadFinished = true; downloadResult = result; }); while (!downloadFinished) { Thread.Sleep(10); } return(downloadResult); }
public string DownloadFile(URLWithISLocal url) { if (url.IsLocal) { return(url.URL); } string tempPath = GetRandomTempFilePath(); if (!DownloadFile(url, tempPath)) { tempPath = string.Empty; } return(tempPath); }
public List <URLWithCDN> ParseLocalResourceListToURL(string localPath, URLWithISLocal commonPath, URLWithISLocal independentPath) { if (!File.Exists(localPath)) { return(null); } string[] fileLines = File.ReadAllLines(localPath); List <URLWithCDN> cdnResList = new List <URLWithCDN>(); for (int i = 0; i < fileLines.Length; i++) { string[] splitedOptions = fileLines[i].Split('#'); if (splitedOptions != null && splitedOptions.Length >= 5) { URLWithISLocal selectedFolderPath = ((splitedOptions[3] == "0") ? (commonPath) : (independentPath)); cdnResList.Add(new URLWithCDN(selectedFolderPath.URL + splitedOptions[0], string.Empty, selectedFolderPath.IsLocal)); } } return(cdnResList); }