Ejemplo n.º 1
0
 //点击更改目录事件
 private void ChangeMenu_Click(object sender, EventArgs e)
 {
     if (FolderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         FilePath = FolderBrowserDialog1.SelectedPath;
         //重启程序
         t.Abort();
         File.Delete("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt");
         StreamWriter sw = new StreamWriter("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt", false);
         sw.WriteLine(FilePath);
         sw.WriteLine(textBoxUser.Text);
         sw.Write(UserLogin.UserManager.GetMD5Hash(textBoxPass.Text));
         sw.Close();
         File.SetAttributes("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt", FileAttributes.Hidden);
         String hostName = textBoxUser.Text + "+" + Dns.GetHostName();
         t = new Sync.TimingSyncThread(hostName, FilePath);
     }
 }
Ejemplo n.º 2
0
        //自动登陆
        private void LoginForm_Load(object sender, EventArgs e)
        {
            if (File.Exists("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt"))
            {
                this.Hide();
                this.ShowInTaskbar = false;
                StreamReader sr = new StreamReader("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt");
                UserLogin.UserManager usma = new UserLogin.UserManager();
                FilePath = sr.ReadLine();
                usma.user = sr.ReadLine();
                usma.pass = sr.ReadToEnd();
                sr.Close();
                if (usma.Login())
                {
                    this.notifyIcon1.Visible = true;
                    string hostName = usma.user + "+" + Dns.GetHostName();
                    t=new Sync.TimingSyncThread(hostName, FilePath);

                }
                else
                {
                    //this.Show();
                    this.ShowInTaskbar = true;
                }
            }
        }
Ejemplo n.º 3
0
        //点击注册,跳转注册页面
        //单击登陆按钮事件
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            UserLogin.UserManager usma = new UserLogin.UserManager();
            usma.user = textBoxUser.Text;
            usma.pass = UserLogin.UserManager.GetMD5Hash(textBoxPass.Text);
            if (usma.Login())
            {
                //暂时先放在这,如果没有FilePath,则创建之,
                if (!Directory.Exists(FilePath))
                {
                    Directory.CreateDirectory(FilePath);
                }
                MessageBox.Show("登录成功,双击托盘图标打开同步的文件夹!", "Easybox");
                this.Hide();
                this.notifyIcon1.Visible = true;
                StreamWriter sw = new StreamWriter("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt",false);
                sw.WriteLine(FilePath);
                sw.WriteLine(usma.user);
                sw.Write(usma.pass);
                sw.Close();
                File.SetAttributes("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt", FileAttributes.Hidden);
                String hostName = usma.user + "+" + Dns.GetHostName();
                t=new Sync.TimingSyncThread(hostName, FilePath);

            }
        }