Пример #1
0
        public static void Run7zip(FileDetail fd, FolderList fl)
        {
            if (System.IO.File.Exists(fd.CompressedName))
            {
                Debug.Print("Deleting existing compressed file: {0}", fd.CompressedName);
                FileHandler.DeleteFile(fd.CompressedName);
            }

            string password = Program.MainForm.config.PasswordText;

            if (!string.IsNullOrEmpty(password))
            {
                password = "******" + password + " -mhe";
            }

            CompressionLevel compLevel = (CompressionLevel)Program.MainForm.config.CompressionLevel;

            RunProcess(Program.MainForm.config.Executable7zip, string.Format(@"a -t7z -y ""{0}"" ""{1}"" {2} -{3}", fd.CompressedName, fd.OriginalName, password, compLevel));

            if (File.Exists(fd.CompressedName))
            {
                FileInfo cFi = new System.IO.FileInfo(fd.CompressedName);
                //fd.CompressedHash = Crypto.GetSHA512Hash(cFi.FullName);
                fd.CompressedTime = cFi.LastWriteTimeUtc;
                fd.CompressedSize = cFi.Length;
            }
        }
Пример #2
0
        private void btnRemoveFolder_Click(object sender, EventArgs e)
        {
            if (lstFolders.SelectedItems.Count > 0)
            {
                FolderList fl = FolderList.list.First(f => f.Source == lstFolders.SelectedItems[0].Text);
                FolderList.list.Remove(fl);

                PopulateFolderList();
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string source = null;
            string target = null;

            folderBrowserDialog1.Description = "Select source folder...";
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                source = folderBrowserDialog1.SelectedPath;

                folderBrowserDialog1.Description = "Select target folder...";
                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    target = folderBrowserDialog1.SelectedPath;
                }
            }

            if (source != null && target != null)
            {
                foreach (FolderList fl in FolderList.list)
                {
                    if (Regex.IsMatch(fl.Source + @"\\", Regex.Escape(source + @"\\")))
                    {
                        MsgManager.Show(string.Format("Source folder is already added would conflict with another folder. {0} > {1}", source, fl.Source), "Add folder", MessageBoxIcon.Error);
                        source = null;
                        break;
                    }

                    if (Regex.IsMatch(fl.Target + @"\\", Regex.Escape(target + @"\\")))
                    {
                        MsgManager.Show(string.Format("Target folder is already added would conflict with another folder. {0} > {1}", target, fl.Target), "Add folder", MessageBoxIcon.Error);
                        target = null;
                        break;
                    }
                }
            }

            if (source != null && target != null)
            {
                FolderList fl = new FolderList();
                fl.Source = source;
                fl.Target = target;
                FolderList.list.Add(fl);

                PopulateFolderList();
            }
        }
Пример #4
0
        private void btnUpdateFolder_Click(object sender, EventArgs e)
        {
            if (lstFolders.SelectedItems.Count > 0)
            {
                if (System.IO.Directory.Exists(txtFolderSource.Text) && System.IO.Directory.Exists(txtFolderTarget.Text))
                {
                    FolderList fl = FolderList.list.First(f => f.Source == lstFolders.SelectedItems[0].Text);

                    fl.Source = txtFolderSource.Text;
                    fl.Target = txtFolderTarget.Text;

                    PopulateFolderList();
                }
                else
                {
                    MsgManager.Show("Source and target folder must exist.", "Update folder", MessageBoxIcon.Error);
                }
            }
        }
Пример #5
0
        private void lstFolders_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstFolders.SelectedItems.Count > 0)
            {
                FolderList fl = FolderList.list.First(f => f.Source == lstFolders.SelectedItems[0].Text);

                txtFolderSource.Text    = fl.Source;
                txtFolderTarget.Text    = fl.Target;
                btnUpdateFolder.Enabled = true;
                btnRemoveFolder.Enabled = true;
            }
            else
            {
                txtFolderSource.Text    = string.Empty;
                txtFolderTarget.Text    = string.Empty;
                btnUpdateFolder.Enabled = false;
                btnRemoveFolder.Enabled = false;
            }
        }