Beispiel #1
0
        private void thread_UpLoad(object param)
        {
            var p = (Tuple<string, int, string>)param;
            string localFileName = p.Item1;
            int fileSize = p.Item2;
            string workid = p.Item3;

            var waits = new List<EventWaitHandle>();
            FtpHelper uploadftp = null;


            var handler = new ManualResetEvent(false);
            waits.Add(handler);

            uploadftp = new FtpHelper();
            uploadftp.Hostname = this.Hostname;
            uploadftp.Username = this.Username;
            uploadftp.Password = this.Password;
            uploadftp.Port = this.Port;

            uploadftp.DelEvent = this.DelEvent;

            uploadftp.isThreadForTransfer = true;
            uploadftp.Remotefolder = this.Remotefolder;
            uploadftp.Localfolder = this.Localfolder;
            uploadftp.Connect();

            uploadftp.Login();

            uploadftp._handler = handler;
            uploadftp.DirChange(uploadftp.Remotefolder );
            uploadftp.UpLoadFile(localFileName,fileSize ,workid );
     
            WaitHandle.WaitAll(waits.ToArray());

            FtpEventArgs e = new FtpEventArgs();
            e.Totalbytes = fileSize;
            //e.Timeelapsed = timeElapsed;
            //e.SMessage = s;
            e.Workid = workid;
            OnFileUpLoadCommpleted (e);
        }
Beispiel #2
0
 public FtpHandler(FtpHelper ftpHelper)
 {
     _ftpHelper = ftpHelper;
     _asyncSocket = null;
 }
Beispiel #3
0
        /// <summary>
        /// 下载线程
        /// </summary>
        /// <param name="param"></param>
        private void thread_DownFile(object param)
        {
            var p = (Tuple<string, int, string,int >)param;
            string serverFileName = p.Item1;
            int fileSize = p.Item2;
            string workid = p.Item3;
            int offset = p.Item4;

            string path = this.Localfolder;
            //CreateFixedSizeFile(path + @"\" + serverFileName + ".tmp", fileSize);

            var waits = new List<EventWaitHandle>();
            FtpHelper downftp = null;
            var handler = new ManualResetEvent(false);
            waits.Add(handler);
            downftp = new FtpHelper();
            downftp.Hostname = this.Hostname;
            downftp.Username = this.Username;
            downftp.Password = this.Password;
            downftp.Port = this.Port;

            downftp.DelEvent = this.DelEvent;
            downftp.isThreadForTransfer = true;
            downftp.Remotefolder = this.Remotefolder;
            downftp.Localfolder = this.Localfolder;
            downftp.Connect();

            downftp.Login();
            downftp._handler = handler;
            downftp.DirChange(downftp.Remotefolder);
            downftp.DowLoadFile(serverFileName, fileSize, workid,offset );

            WaitHandle.WaitAll(waits.ToArray());

            FtpEventArgs e = new FtpEventArgs();
            e.Totalbytes = fileSize;
            //e.Timeelapsed = timeElapsed;
            //e.SMessage = s;
            e.Workid = p.Item3;
            OnFileDownLoadCommpleted(e);
        }