Exemple #1
0
        //private   void button2_Click_1(object sender, EventArgs e)
        //{
        //    Debug.WriteLine("start----");
        //    Debug.WriteLine("end----");
        //}
        //private void button4_Click(object sender, EventArgs e)
        //{
        //    mesController.GetTaskResult();
        //}

        protected override void WndProc(ref Message m)
        {
            Udisk.DeviceChanged(ref m);
            base.WndProc(ref m);
        }
Exemple #2
0
        public static CopyResult CopyFilesToUDisk(string srcDir, List <string> filelist)
        {
            CopyResult result     = 0;
            bool       uexist     = false;
            bool       ustorageok = false;

            List <string> Udisks = new List <string>();

            //find all removable disks
            DriveInfo[] drvInfos = DriveInfo.GetDrives();
            foreach (DriveInfo drv in drvInfos)
            {
                Debug.WriteLine(drv.ToString());
                if (drv.DriveType == DriveType.Removable)
                {
                    uexist = true;
                    Messages.WriteLine("U盘容量:" + drv.TotalSize);
                    if (7000000000 < drv.TotalSize && drv.TotalSize < 9000000000)
                    {
                        Udisks.Add(drv.ToString());
                        ustorageok = true;
                        break;
                        // Debug.WriteLine(i.ToString());
                    }
                }
            }

            //copy file

            bool copyComplete = false;

            foreach (string u in Udisks)
            {
                Messages.WriteLine(string.Format("文件复制:{0} 到 {1}", srcDir, u));
                if (FileSys.CopyFiles(srcDir, u, filelist))
                {
                    copyComplete = true;
                    Messages.WriteLine("文件复制成功");
                }
                Messages.WriteLine("弹出U盘");
                Udisk.Reject(u);
                break;//copy file to the first udisk then break;
            }

            if (uexist && ustorageok && copyComplete)
            {
                result = CopyResult.GOOD;
            }
            else if (!uexist || !ustorageok)
            {
                result = CopyResult.MISSTORAGE;
            }
            else if (!copyComplete)
            {
                result = CopyResult.COPYFAILED;
            }
            else
            {
                result = CopyResult.UNKNOWN;
            }

            Messages.WriteLine("文件复制结果:" + result.ToString());

            return(result);
        }