コード例 #1
0
        protected void BDown_Click(object sender, EventArgs e)
        {
            DownFileDel down = FileUDHelper.DownFile;
            ProgMod     prog = new ProgMod();

            Session["ProgMod"] = prog;
            IAsyncResult result = down.BeginInvoke("http://code.z01.com/ffmpeg.exe", "/Tools/ffmpeg.exe", prog, null, null);

            function.Script(this, "beginCheck('getProgress');");
        }
コード例 #2
0
        private void update_Shown(object sender, EventArgs e)
        {
            DownFileDel dfd = new DownFileDel(DownFile);

            this.Refresh();
            checkDir.Text = "正在获取校验文件";
            checkDir.Refresh();
            checkFile.Text = "md5.txt";
            checkFile.Refresh();
            WebClient md5file = new WebClient();

            md5file.DownloadFile("http://file.bangbang93.com/2dmmc4th/md5.txt", "rmd5.txt");
            StreamReader rmd5 = new StreamReader("rmd5.txt");

            checkDir.Text = "正在读取校验文件";
            checkDir.Refresh();
            string[,] md5 = new string[2000, 2];
            int i = 0;

            while (rmd5.EndOfStream == false)
            {
                string   str     = rmd5.ReadLine();
                string[] spliter = { "|" };
                md5[i, 0] = str.Split(spliter, StringSplitOptions.RemoveEmptyEntries)[0];
                md5[i, 1] = str.Split(spliter, StringSplitOptions.RemoveEmptyEntries)[1];
                i++;
            }
            int total = i;

            progressBar1.Maximum = total;
            for (i = 0; i <= total; i++)
            {
                try
                {
                    progressBar1.Value++;
                }
                catch { }
                if (md5[i, 0] == null)
                {
                    break;
                }
                string lmd5 = "";
                if (File.Exists(Environment.CurrentDirectory + @"\.minecraft" + md5[i, 0]))
                {
                    try
                    {
                        lmd5 = GetMD5HashFromFile(Environment.CurrentDirectory + @"\.minecraft" + md5[i, 0]);
                    }
                    catch
                    {
                        if (MessageBox.Show("minecraft程序文件被占用,是否尝试强行解除占用(如果此信息重复出现,请换个姿势再尝试)", "文件被占用", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
                        {
                            Form1.launcher.Kill();
                            this.DialogResult = DialogResult.Retry;
                            this.Close();
                            return;
                        }
                    }
                }
                checkDir.Text = md5[i, 0].Substring(0, md5[i, 0].LastIndexOf(@"\"));
                checkDir.Refresh();
                checkFile.Text = md5[i, 0].Substring(md5[i, 0].LastIndexOf(@"\"), md5[i, 0].Length - md5[i, 0].LastIndexOf(@"\"));
                checkFile.Refresh();
                if (lmd5 != md5[i, 1])
                {
                    downFile.Text = "正在下载" + md5[i, 0] + "|" + yunfile.getFileInfo("/2dmmc4th" + md5[i, 0])["size"] + "字节";
                    if (Convert.ToInt32(yunfile.getFileInfo("/2dmmc4th" + md5[i, 0])["size"]) == 0)
                    {
                        File.Delete(md5[i, 0]);
                    }
                    downFile.Refresh();
                    IAsyncResult res = dfd.BeginInvoke("/2dmmc4th" + md5[i, 0], null, null);
                    while (!res.IsCompleted)
                    {
                        Thread.Sleep(50);
                        Application.DoEvents();
                    }
                    byte[] downfile = dfd.EndInvoke(res);
                    //byte[] downfile = yunfile.readFile("/2dmmc4th" + md5[i, 0]);
                    if (!Directory.Exists(md5[i, 0].Substring(0, md5[i, 0].LastIndexOf('\\'))))
                    {
                        Directory.CreateDirectory(md5[i, 0].Substring(0, md5[i, 0].LastIndexOf('\\')));
                    }
                    FileStream writer = new FileStream(Environment.CurrentDirectory + @"\.minecraft" + md5[i, 0], FileMode.Create);
                    writer.Write(downfile, 0, downfile.Length);
                    downFile.Text = "";
                    downFile.Refresh();
                }
            }
            this.Close();
        }
コード例 #3
0
ファイル: update.cs プロジェクト: Elenw/2dmmclauncher4th
        private void update_Shown(object sender, EventArgs e)
        {
            DownFileDel dfd = new DownFileDel(DownFile);
            this.Refresh();
            checkDir.Text = "正在获取校验文件";
            checkDir.Refresh();
            checkFile.Text = "md5.txt";
            checkFile.Refresh();
            WebClient md5file = new WebClient();
            md5file.DownloadFile("http://file.bangbang93.com/2dmmc4th/md5.txt", "rmd5.txt");
            StreamReader rmd5 = new StreamReader("rmd5.txt");
            checkDir.Text = "正在读取校验文件";
            checkDir.Refresh();
            string[,] md5 = new string[2000, 2];
            int i = 0;
            while (rmd5.EndOfStream == false)
            {
                string str = rmd5.ReadLine();
                string[] spliter = { "|" };
                md5[i, 0] = str.Split(spliter, StringSplitOptions.RemoveEmptyEntries)[0];
                md5[i, 1] = str.Split(spliter, StringSplitOptions.RemoveEmptyEntries)[1];
                i++;
            }
            int total = i;
            progressBar1.Maximum = total;
            for (i = 0; i <= total; i++)
            {
                try
                {
                    progressBar1.Value++;
                }
                catch { }
                if (md5[i, 0]==null )
                {
                    break;
                }
                string lmd5="";
                if (File.Exists(Environment.CurrentDirectory + @"\.minecraft" + md5[i, 0]))
                {
                    try
                    {
                        lmd5 = GetMD5HashFromFile(Environment.CurrentDirectory + @"\.minecraft" + md5[i, 0]);
                    }
                    catch
                    {
                        if (MessageBox.Show("minecraft程序文件被占用,是否尝试强行解除占用(如果此信息重复出现,请换个姿势再尝试)", "文件被占用", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
                        {
                            Form1.launcher.Kill();
                            this.DialogResult = DialogResult.Retry;
                            this.Close();
                            return;
                        }

                    }
                }
                checkDir.Text=md5[i,0].Substring(0,md5[i,0].LastIndexOf(@"\"));
                checkDir.Refresh();
                checkFile.Text = md5[i, 0].Substring(md5[i, 0].LastIndexOf(@"\"), md5[i, 0].Length - md5[i, 0].LastIndexOf(@"\"));
                checkFile.Refresh();
                if (lmd5 != md5[i, 1])
                {
                    downFile.Text = "正在下载" + md5[i,0]+"|"+yunfile.getFileInfo("/2dmmc4th"+md5[i,0])["size"]+"字节";
                    if (Convert.ToInt32( yunfile.getFileInfo("/2dmmc4th" + md5[i, 0])["size"]) == 0)
                    {
                        File.Delete(md5[i, 0]);
                    }
                    downFile.Refresh();
                    IAsyncResult res = dfd.BeginInvoke("/2dmmc4th" + md5[i, 0], null, null);
                    while (!res.IsCompleted)
                    {
                        Thread.Sleep(50);
                        Application.DoEvents();
                    }
                    byte[] downfile = dfd.EndInvoke(res);
                    //byte[] downfile = yunfile.readFile("/2dmmc4th" + md5[i, 0]);
                    if (!Directory.Exists(md5[i,0].Substring(0,md5[i,0].LastIndexOf('\\'))))
                    {
                        Directory.CreateDirectory(md5[i,0].Substring(0,md5[i,0].LastIndexOf('\\')));
                    }
                    FileStream writer = new FileStream(Environment.CurrentDirectory + @"\.minecraft" + md5[i, 0], FileMode.Create);
                    writer.Write(downfile, 0, downfile.Length);
                    downFile.Text = "";
                    downFile.Refresh();
                }
            }
            this.Close();
        }