Exemplo n.º 1
0
        public FTPWriter(BuildViewModel _BVM)
        {
            if (Properties.Settings.Default.FTPValid)
            {
                BVM = _BVM;

                Adress   = Properties.Settings.Default.FTPAddress.Split(':')[0];
                Port     = Properties.Settings.Default.FTPAddress.Split(':')[1];
                Username = Properties.Settings.Default.FTPUN;
                Password = Properties.Settings.Default.FTPPW;

                Client                = new FtpClient(Adress);
                Client.Port           = int.Parse(Port);
                Client.ConnectTimeout = 3000;
                if (Username != "")
                {
                    Client.Credentials = new System.Net.NetworkCredential(Username, Password);
                }

                Client.RecursiveList = true;

                Progress = delegate(FtpProgress p) {
                    if (p.Progress != 100)
                    {
                        BVM.SetSpeed(String.Format("{0}/s, {1}%", WriterOperations.BytesToString(p.TransferSpeed), p.Progress.ToString().Substring(0, 2)));
                    }
                };
            }
        }
Exemplo n.º 2
0
        public override bool SendFile(string SourceFilePath, string FilePath)
        {
            BVM.SetSize(String.Format("Current File Size : {0}", WriterOperations.BytesToString(new FileInfo(SourceFilePath).Length)));
            Log.Debug(String.Format("Updating File {0} - {1}", SourceFilePath, FilePath));
            FtpStatus Status = Client.UploadFile(SourceFilePath, FilePath, FtpRemoteExists.Overwrite, true, FtpVerify.None, Progress);

            return(Status.IsSuccess());
        }