Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text     = "下载实验或试卷中。。。";
            button1.Enabled = false;
            System.DateTime currentTime = DateTime.Now;
            ////////////////////////////////////////////
            try
            {
                bool first;
                first = true;
                if (Directory.Exists(@"c:\downloadFTP"))
                {
                    GenInfo.deldir(@"c:\downloadFTP");
                }

                if (Directory.Exists(@"c:\" + userid + username + "-" + currentTime.ToString("m") + @"上传文件夹"))
                {
                    first = false;
                }
                downloadPaper pa = new downloadPaper();
                pa.downftp("ftp://192.168." + ConfigurationManager.AppSettings["ftpip"].ToString() + teacher + "/download", @"/", @"c:\downloadFTP");
                GenInfo.GenFile(username, userid, Getinfo.GetClientLocalIPv4Address(), Getinfo.GetMacAddress());
                if (first)
                {
                    GenInfo.Copy(@"c:\downloadFTP", @"c:\" + userid + username + "-" + currentTime.ToString("m") + @"上传文件夹");
                }
                ////////////
                string filePath = @"c:\" + userid + currentTime.ToString("m") + @"download";

                if (Directory.Exists(@"c:\downloadFTP"))
                {
                    GenInfo.deldir(@"c:\downloadFTP");
                }

                ///////////

                button2.Enabled = true;
                button3.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "请正确填写和选择信息下载不成功 ");
            }


            //////////////////////////////////////////


            label1.Text = "";
            MessageBox.Show("下载完成");
            // button1.Enabled = false;
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     textBox1.Text = Getinfo.GetMacAddress();
     textBox2.Text = Getinfo.GetClientLocalIPv4Address();
 }
Exemplo n.º 3
0
        /// <summary>
        /// /////////////////////
        ///
        ///
        protected override void WndProc(ref Message m)
        {
            try
            {
                if (m.Msg == WM_DEVICECHANGE)
                {
                    switch (m.WParam.ToInt32())
                    {
                    case WM_DEVICECHANGE:
                        break;

                    case DBT_DEVICEARRIVAL:    //U盘插入
                        DriveInfo[] s = DriveInfo.GetDrives();
                        foreach (DriveInfo drive in s)
                        {
                            if (drive.DriveType == DriveType.Removable)
                            {
                                // label1.Text = "U盘已插入,盘符为:" + drive.Name.ToString();
                                UploadFileFTP up = new UploadFileFTP();
                                up.GenFileUpFTP(username, userid, Getinfo.GetClientLocalIPv4Address(), Getinfo.GetMacAddress(), "ftp://192.168." + ConfigurationManager.AppSettings["ftpip"].ToString() + teacher + "/upload");

                                MessageBox.Show("同学你插入U盘了,如是考试,我要告诉老师哦,盘符为:" + drive.Name.ToString());


                                break;
                            }
                        }
                        break;

                    case DBT_CONFIGCHANGECANCELED:
                        break;

                    case DBT_CONFIGCHANGED:
                        break;

                    case DBT_CUSTOMEVENT:
                        break;

                    case DBT_DEVICEQUERYREMOVE:
                        break;

                    case DBT_DEVICEQUERYREMOVEFAILED:
                        break;

                    case DBT_DEVICEREMOVECOMPLETE:       //U盘卸载
                        //label1.Text = "";
                        break;

                    case DBT_DEVICEREMOVEPENDING:
                        break;

                    case DBT_DEVICETYPESPECIFIC:
                        break;

                    case DBT_DEVNODES_CHANGED:
                        break;

                    case DBT_QUERYCHANGECONFIG:
                        break;

                    case DBT_USERDEFINED:
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            base.WndProc(ref m);
        }