Ejemplo n.º 1
0
 public void Add(FileQueueItem f)
 {
     counter++;
     fiList.Add(f);
     Console.WriteLine("added to file queue: {0}", f.CommonPath);
 }
Ejemplo n.º 2
0
 public void Add(FileQueueItem f)
 {
     counter++;
     fiList.Add(f);
     Console.WriteLine("added to file queue: {0}", f.CommonPath);
 }
Ejemplo n.º 3
0
        public static void Upload(FileQueueItem i)
        {
            string temp = Common._tempName(i.CommonPath);

            //upload to a temp file...
            if (Profile.Protocol != FtpProtocol.SFTP)
                ftpc.PutFile(i.LocalPath, temp, FileAction.Create);
            else
                using (var file = File.OpenRead(i.LocalPath))
                    sftpc.UploadFile(file, temp, true);
        }
Ejemplo n.º 4
0
        private void SyncArgItems(string[] args)
        {
            int valid_items = 0;
            foreach (string s in args)
            {
                string cpath = Common.GetComPath(s, true);

                if (!s.StartsWith(Profile.LocalPath))
                {
                    MessageBox.Show("You cannot use this for files that are not inside the FTPbox folder.", "FTPbox - Invalid file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                if (Common.PathIsFile(s) && File.Exists(s))
                {
                    //FileInfo fli = new FileInfo(s);
                    FileQueueItem fi = new FileQueueItem(cpath, s, Client.SizeOf(cpath), TypeOfTransfer.Change);
                    fQueue.MenuFiles.Add(fi);
                    valid_items++;
                }
                else if (!Common.PathIsFile(s) && Directory.Exists(s))
                {
                    fQueue.MenuFolders.Add(s);
                    valid_items++;
                }
            }

            if (valid_items == 0) return;

            if (fQueue.Busy)
            {
                arEvent.WaitOne();
            }

            SetTray(MessageType.Syncing);
            fQueue.Busy = true;
            foreach (FileQueueItem fqi in fQueue.MenuFiles)
            {
                DateTime rDT = Client.GetLWTof(fqi.CommonPath);
                CheckExistingFile(fqi.CommonPath, rDT, fqi.LocalPath, fqi.Size);

                SyncRemQueueFiles();
            }
            foreach (string dqi in fQueue.MenuFolders)
                StartRemoteSync(Common.GetComPath(dqi, true));
            /*
                foreach (string fi in Directory.GetFiles(dqi, "*", SearchOption.AllDirectories))
                {
                    string cpath = Common.GetComPath(fi, true);
                    DateTime rDT = GetLWTof(cpath);
                    FileInfo iFile = new FileInfo(fi);
                    CheckExistingFile(cpath, rDT, fi, iFile.Length);
                }*/

            SetTray(MessageType.AllSynced);

            arEvent.Set();
        }
Ejemplo n.º 5
0
        public static void Download(FileQueueItem i)
        {
            string temp = Common._tempLocal(i.LocalPath);

            if (Profile.Protocol != FtpProtocol.SFTP)
            {
                if (i.PathToFile.Contains(" "))
                {
                    string cd = WorkingDirectory;
                    ftpc.ChangeDirectoryMultiPath(i.PathToFile);
                    ftpc.GetFile(Common._tempName(Common._name(i.CommonPath)), temp, FileAction.Create);
                    while (WorkingDirectory != cd)
                        ftpc.ChangeDirectoryUp();
                }
                else
                    ftpc.GetFile(i.CommonPath, temp, FileAction.Create);
            }
            else
                using (FileStream f = new FileStream(temp, FileMode.Create, FileAccess.ReadWrite))
                    sftpc.DownloadFile(i.CommonPath, f);
        }