예제 #1
0
파일: Form1.cs 프로젝트: bzhu3216/FTPtool
        private void button3_Click(object sender, EventArgs e)
        {
            UploadFileFTP up = new UploadFileFTP();

            //up.UploadDirectory(@"c:\" , "ftp://192.168.131.219/", textBox3.Text + textBox2.Text);
            up.UploadDirectory(@"c:\", ConfigurationManager.AppSettings["ftpip"], textBox3.Text + textBox2.Text);


            MessageBox.Show("上传成功!");
            // up.MakeDir("ftp://192.168.131.219/", textBox3.Text + textBox2.Text);
            //textBox3.Text=up.CheckDirectoryExist("ftp://192.168.131.219/", textBox3.Text + textBox2.Text).ToString();
            // textBox5.Text = (up.CheckDirectoryExist2("ftp://192.168.131.219/", textBox3.Text + textBox2.Text)).ToString();
        }
예제 #2
0
파일: main.cs 프로젝트: bzhu3216/FTPtool
        private void button2_Click(object sender, EventArgs e)
        {
            UploadFileFTP up = new UploadFileFTP();

            System.DateTime currentTime = DateTime.Now;

            if (GenInfo.Checkfile(@"c:\" + userid + username + "-" + currentTime.ToString("m") + @"上传文件夹\", "log.dat"))
            {
                button2.Enabled = false;
                label1.Text     = "上传文件中。。。";

                up.UploadDirectory(@"c:\", "ftp://192.168." + ConfigurationManager.AppSettings["ftpip"] + teacher + @"/upload/", userid + username + "-" + currentTime.ToString("m") + @"上传文件夹");
                MessageBox.Show("上传成功!");
                label1.Text     = "";
                button2.Enabled = true;
            }
            else
            {
                MessageBox.Show("你删除了系统文件,联系老师!");
            }
        }
예제 #3
0
파일: main.cs 프로젝트: bzhu3216/FTPtool
        private void button3_Click(object sender, EventArgs e)
        {
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result;

            Dnshelp.setDNS("202.121.241.8");

            string   message = "确定要退出吗?";
            string   caption = "退出";
            abnormal ab      = new abnormal();

            result = MessageBox.Show(message, caption, buttons);
            System.DateTime currentTime = DateTime.Now;
            UploadFileFTP   up          = new UploadFileFTP();

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {      // if (up.CheckDirectoryExist2("ftp://192.168." + ConfigurationManager.AppSettings["ftpip"] + teacher + @"/upload/", userid + username + "-" + currentTime.ToString("m") + @"上传文件夹"))
                    if (ab.CompareDir(@"c:\", "ftp://192.168." + ConfigurationManager.AppSettings["ftpip"] + teacher + @"/upload/", userid + username + "-" + currentTime.ToString("m") + @"上传文件夹"))
                    {
                        label1.Text = "正在退出。。。";

                        Application.Exit();
                    }
                    else
                    {
                        MessageBox.Show("文件有更新请上传文件后退出");
                    }
                }
                catch (Exception ex)
                {
                    // MessageBox.Show(ex.Message+"异常,请联系老师 ");

                    // Application.Exit();
                    MessageBox.Show("文件有更新请上传文件后退出");
                }
            }
        }
예제 #4
0
        /////////////////////////////////////////////////////////////////////////

        public static void  deldir(string dir)

        {
            string        pd_1 = dir;
            UploadFileFTP up   = new UploadFileFTP();

            ///////////
            //string dir = localDir + dirName + @"\"; //获取当前目录(父目录在目录名)
            //string dir = localDir + dirName + @"\";
            //检测本地目录是否存在
            if (!Directory.Exists(pd_1))
            {
                //Response.Write("本地目录:“" + dir + "” 不存在!<br/>");
                //  MessageBox.Show("本地目录:“" + pd_1 + "” 不存在111!");
            }
            else
            {
                List <List <string> > infos = up.GetDirDetails(pd_1); //获取当前目录下的所有文件和文件夹

                //先上传文件
                //Response.Write(dir + "下的文件数:" + infos[0].Count.ToString() + "<br/>");
                for (int i = 0; i < infos[0].Count; i++)
                {
                    // Console.WriteLine(infos[0][i]);
                    File.Delete(pd_1 + @"\" + infos[0][i]);
                }
                //再处理文件夹
                //Response.Write(dir + "下的目录数:" + infos[1].Count.ToString() + "<br/>");
                for (int i = 0; i < infos[1].Count; i++)
                {
                    deldir(pd_1 + @"\" + infos[1][i]);
                }
                Directory.Delete(pd_1);
            }
            ///////
        }
예제 #5
0
 public abnormal()
 {
     up = new UploadFileFTP();
 }
예제 #6
0
파일: main.cs 프로젝트: bzhu3216/FTPtool
        /// <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);
        }