Exemple #1
0
 private void DoCopy2()
 {
     SetPBC2(PBC2, FFiles[0]);
     //for (i = 0; i < P1.Count; i++)//0:安裝資料夾 1:PKG 2:System 3:MODI
     {
         PBC2.Properties.Maximum = FFiles[0].Length;
         PBC2.Position           = 0;
         for (int j = 0; j < FFiles[0].Length; j++)
         {
             lb_Source.Text      = FFiles[0][j];
             lb_Destination.Text = FFiles[1][j];
             System.IO.File.Copy(lb_Source.Text, lb_Destination.Text, true);
             Application.DoEvents();
             PBC2.PerformStep();
         }
     }
 }
Exemple #2
0
        private void DoCopy()
        {
            try
            {
                if (P2[1].Length > 0) //20130904 ADD 新增只下載MODI
                {
                    if (!fc.isDirectory(P1[3][1]))
                    {
                        Directory.CreateDirectory(P1[3][1]);
                    }
                    string[] s     = Directory.GetFiles(P1[3][1]);
                    string   error = "";
                    if (s.Length > 0)
                    {
                        //if (fc.ShowBoxMessage("是否刪除MODI下檔案?", "詢問", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            try
                            {
                                foreach (string str in s)
                                {
                                    File.Delete(str);
                                    error = str;
                                    Fmsg += "[" + DateTime.Now.ToString() + "] " + "已刪除 " + error + "\r\n";
                                }
                                Fmsg += "[" + DateTime.Now.ToString() + "] " + P1[3][1] + " 已打掃乾淨!\r\n";
                            }
                            catch (System.Exception ex)
                            {
                                Fmsg += "[" + DateTime.Now.ToString() + "] " + "刪除MODI檔案發生錯誤 <<" + error + ">>" + ex.Message.ToString() + "\r\n";
                                fc.ShowBoxMessage("刪除MODI檔案發生錯誤 <<" + error + ">>" + ex.Message.ToString() + "\r\n");
                                timer2.Enabled = true;

                                //throw;
                            }
                        }
                    }
                }
                SetPBC2(PBC1, P1);
                SetPBC2(PBC2, P2);
                int i   = 0;
                int j   = 0;
                int max = 0;
                if (P2[0].Length > 0)
                {
                    max++;
                }
                if (P2[1].Length > 0)
                {
                    max++;
                }
                if (P2[2].Length > 0)
                {
                    max++;
                }
                if (P2[3].Length > 0)
                {
                    max++;
                }
                PBC1.Properties.Maximum = max;
                if (CheckFileIsLock())//檢查是否有被LOCK的檔案
                {
                    BoxListBox b = new BoxListBox();
                    b.SetListBox = FileLockedList;
                    if (b.ShowDialog() == DialogResult.OK)
                    {
                        Fmsg = b.GetMsg;
                    }
                    else
                    {
                        Fmsg = "[" + DateTime.Now.ToString() + "] " + "有檔案正在使用中,停止下載程序!";
                        return;
                    }
                }

                for (i = 0; i < P1.Count; i++)//0:安裝資料夾 1:PKG 2:System 3:MODI
                {
                    PBC2.Properties.Maximum = P2[i].Length;
                    PBC2.Position           = 0;
                    for (j = 0; j < P2[i].Length; j++)
                    {
                        if (!Directory.Exists(P1[i][1]))
                        {
                            Directory.CreateDirectory(P1[i][1]);
                        }
                        lb_Source.Text      = P1[i][0] + @"\" + P2[i][j];
                        lb_Destination.Text = P1[i][1] + @"\" + P2[i][j];
                        System.IO.File.Copy(lb_Source.Text, lb_Destination.Text, true);

                        Application.DoEvents();
                        PBC2.PerformStep();
                    }
                    if (P2[i].Length > 0)
                    {
                        Application.DoEvents();
                        PBC1.PerformStep();
                    }
                }
                Fmsg += "[" + DateTime.Now.ToString() + "] " + "打包成功!!\r\n";
            }
            catch (System.Exception ex)
            {
                Fmsg = "[" + DateTime.Now.ToString() + "] " + ex.Message.ToString() + "\r\n";
                fc.ShowBoxMessage(ex.Message.ToString() + "\r\n");
                timer2.Enabled = true;

                //throw;
            }
        }