Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                TcpClient tcp = new TcpClient();
                tcp.Connect(_server, _port);

                TclientConnection con = new TclientConnection(tcp, listBox1);
                Thread t = new Thread(new ThreadStart(con.GetFileList));
                t.IsBackground = true;
                t.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void DownFile(string fileName, string path, long fileLength)
        {
            #region 保存最后下载的信息
            _sysConfig.SetIniString("LastDownFile", fileName);
            _sysConfig.SetIniString("LastDownFilePath", path);
            _sysConfig.SetIniString("LastDownFileLength", fileLength.ToString());
            #endregion

            #region 初始化进度条
            p.Maximum = 100;
            p.Minimum = 0;
            p.Value = 0;
            #endregion

            #region 启动下载线程
            try
            {
                TcpClient tcp = new TcpClient();
                tcp.Connect(_server, _port);

                TclientConnection con = new TclientConnection(tcp, fileName, path, fileLength, p);
                Thread t = new Thread(new ThreadStart(con.GetFile));
                t.IsBackground = true;
                t.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }