Ejemplo n.º 1
0
        private void BWOnDoWork(object sender, DoWorkEventArgs e)
        {
            if (!(e.Argument is NodeListItem))
            {
                return;
            }
            var src  = e.Argument as NodeListItem;
            var list = new List <Xisoftp.FTPDirList>();

            if (!Xisoftp.GetDirListing(src.Src, ref list))
            {
                e.Result = Xisoftp.LastError;
                return;
            }
            foreach (var ftpDirList in list)
            {
                var node = new TreeNode(ftpDirList.Name)
                {
                    ImageKey         = ftpDirList.IsDirectory ? "folder" : "file",
                    SelectedImageKey = ftpDirList.IsDirectory ? "folder" : "file"
                };
                switch (src.Src)
                {
                case null:
                    AddNewNode(node);
                    break;

                default:
                    AddNewChildNode(node, src.Node);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 private void DisconnectbtnClick(object sender, EventArgs e)
 {
     Xisoftp.Disconnect();
     HostboxTextChanged(null, null);
     disconnectbtn.Visible = false;
     disconnectbtn.Enabled = false;
 }
Ejemplo n.º 3
0
 private void FTPSettingsFormClosing(object sender, FormClosingEventArgs e)
 {
     e.Cancel = true;
     if (Xisoftp.IsConnected)
     {
         Xisoftp.Disconnect();
     }
     e.Cancel = false;
 }
Ejemplo n.º 4
0
        private void ConworkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (!(e.Argument is FTPConnectionSettings))
            {
                return;
            }
            var settings = e.Argument as FTPConnectionSettings;

            e.Result = Xisoftp.Connect(settings.Host, settings.Port, settings.DataConnectionType, settings.User, settings.Password);
        }
Ejemplo n.º 5
0
 private void SaveBtnClick(object sender, EventArgs e)
 {
     Xisoftp.Disconnect();
     Program.Form.FtpSettings.Host               = hostbox.Text;
     Program.Form.FtpSettings.User               = userbox.Text;
     Program.Form.FtpSettings.Password           = passbox.Text;
     Program.Form.FtpSettings.Port               = (int)portbox.Value;
     Program.Form.FtpSettings.DataConnectionType = GetConnectionType();
     Program.Form.FtpSettings.Path               = pathbox.Text;
 }
Ejemplo n.º 6
0
        private void MainFormFormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            if (bw.IsBusy)
            {
                AbortOperation(sender, e);
                while (bw.IsBusy)
                {
                    Thread.Sleep(100);
                    Application.DoEvents();
                }
            }
#if !NOFTP
            if (Xisoftp.IsConnected)
            {
                Xisoftp.Disconnect();
            }
#endif
            e.Cancel = false;
        }
Ejemplo n.º 7
0
 private static bool ExtractFiles(ref BinaryReader br, ref List <XisoTableData> list, Xisoftp.FTPSettingsData ftpOpts, XisoOptions xisoOpts)
 {
     _totalProcessed = 0;
     if (list.Count == 0)
     {
         return(false);
     }
     UpdateStatus("Connecting to server...");
     if (!Xisoftp.Connect(ftpOpts.Host, ftpOpts.Port, ftpOpts.DataConnectionType, ftpOpts.User, ftpOpts.Password))
     {
         UpdateStatus(string.Format("Connection failed! Last Error: {0}", Xisoftp.LastError));
         return(false);
     }
     if (!Xisoftp.SetDirectory(ftpOpts.Path))
     {
         UpdateStatus(string.Format("Set Directory Failure! Last Error: {0}", Xisoftp.LastError));
         Xisoftp.Disconnect();
         return(false);
     }
     UpdateStatus(string.Format("Creating Directory: {0}", xisoOpts.Target));
     if (!Xisoftp.CreateDirectory(xisoOpts.Target))
     {
         UpdateStatus(string.Format("Create target Directory Failure! Last Error: {0}", Xisoftp.LastError));
         Xisoftp.Disconnect();
         return(false);
     }
     ftpOpts.Path += xisoOpts.Target;
     UpdateStatus(string.Format("Extracting files to ftp:{0}", ftpOpts.Path));
     UpdateOperation(string.Format("Extracting files to ftp:{0}", ftpOpts.Path));
     foreach (var entry in list)
     {
         if (entry.IsFile)
         {
             continue;
         }
         var dir = ftpOpts.Path + (entry.Path.Substring(1) + entry.Name).Replace("\\", "/");
         UpdateStatus(string.Format("Creating Directory: {0}", dir));
         Xisoftp.CreateDirectory(dir);
     }
     foreach (var entry in list)
     {
         if (Abort)
         {
             return(false);
         }
         if (!entry.IsFile)
         {
             continue;
         }
         if (!Xisoftp.SetDirectory((ftpOpts.Path + entry.Path.Replace("\\", "/")).Replace("//", "/")))
         {
             UpdateStatus(string.Format("Set Directory Failure! Last Error: {0}", Xisoftp.LastError));
             Xisoftp.Disconnect();
             return(false);
         }
         UpdateStatus(string.Format("Extracting {0}{1} ({2})", entry.Path, entry.Name, Utils.GetSizeReadable(entry.Size)));
         if (!Xisoftp.SendFile(entry.Name, ref br, entry.Offset, entry.Size, xisoOpts, entry.Path))
         {
             UpdateStatus(string.Format("Send File Failure! Last Error: {0}", Xisoftp.LastError));
             Xisoftp.Disconnect();
             return(false);
         }
     }
     if (xisoOpts.GenerateSfv)
     {
         xisoOpts.SfvGen.Save();
     }
     return(true);
 }