Пример #1
0
        public ActionResult DownLoadSth(string url)
        {
            string filePath = Server.MapPath("~") + url;
            long   speed    = 5000000;

            DownLoadHelper.DownloadFile(HttpContext, filePath, speed);
            return(View());
        }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         DownLoadHelper.DownLoadLocalFile("/Content/template/BOM模版.xls");
     }
     catch (Exception ex)
     {
         Response.Write("Error:" + ex.Message);
     }
 }
Пример #3
0
        public void Down_ThreadFun(object par)
        {
            string[] pars     = par as string[];
            string   url      = pars[0];
            string   savePath = pars[1];
            string   fileName = pars[2];
            string   type     = pars[3];

            DateTime start = DateTime.Now;

            long v = -1;

            long.TryParse(this.textBox21.Text.Trim(), out v);
            this.textBox21.Text = v.ToString();

            bool   re       = new DownLoadHelper().DownLoadFile(url, savePath, fileName, v);
            string filepath = savePath + "\\" + fileName;

            double size = StMath.ToPrecision(StFile.GetFileSize(filepath) * 1.0 / 1000000, 2);
            double t    = StMath.ToPrecision((DateTime.Now - start).TotalSeconds, 2);

            this.label18.Text = "上次下载" + type + "( " + fileName + " ) " + size + "M 共耗时 " + t + " 秒,平均 " + StMath.ToPrecision(size / t, 2) + "M/s ";
        }
Пример #4
0
        /// <summary>
        /// fetch project template
        /// </summary>
        /// <returns>path of project template zip file.</returns>
        public async Task <string> Fetch()
        {
            Console.WriteLine($"Querying Releases From Github.com/{UserName}/{RepoName}@{ReleaseTag}...");
            var release = await QueryRelaseFromGithub();

            var projectTemplateFileName = $"{release.Author.Login}_{RepoName}@{release.TagName}.zip";
            var tplFilePath             = Path.Combine(Consts.TemplateFilesRoot, $".{Path.DirectorySeparatorChar}{projectTemplateFileName}");

            if (File.Exists(tplFilePath))
            {
                return(tplFilePath);
            }
            else
            {
                if (!Directory.Exists(Consts.TemplateFilesRoot))
                {
                    Directory.CreateDirectory(Consts.TemplateFilesRoot);
                }

                DownLoadHelper.DownLoadZipFile(release.ZipballUrl, tplFilePath);

                return(tplFilePath);
            }
        }