Beispiel #1
0
        private void move(String path)
        {
            Configuration c = DataManagerConf.read().FirstOrDefault();

            c.LastFolder = path;
            string newName = this.fileInfo.Name;
            string newpath = c.LastFolder + "\\" + newName;

            bool moved = false;

            try {
                if (File.Exists(newpath))
                {
                    newName = DateTime.Now.ToString("yyyyMMddHHmmss") + newName;
                    newpath = c.LastFolder + "\\" + newName;
                }
                File.Move(this.fileInfo.FullPath, newpath);
                moved = true;
            } catch (Exception ex) {
                moved = false;
                MessageBox.Show("Error during move file operation : " + ex.Message);
            }
            if (moved)
            {
                this.mainForm.f.Remove(this.fileInfo.FullPath);
                this.fileInfo = new FileSystemEventArgs(this.fileInfo.ChangeType, c.LastFolder, newName);
                bind();
                DataManagerConf.write(c);
            }
        }
Beispiel #2
0
        private void frmMoveFile_Load(object sender, EventArgs e)
        {
            bind();
            Configuration c = DataManagerConf.read().FirstOrDefault();

            btnMoveToLast.Visible = (c != null && !string.IsNullOrEmpty(c.LastFolder));
            if (btnMoveToLast.Visible)
            {
                btnMoveToLast.Text = "Move To:" + c.LastFolder;
            }
        }
        public frmConfiguration(MainForm mainForm)
        {
            InitializeComponent();
            this.mainForm = mainForm;
            Configuration c = DataManagerConf.read().FirstOrDefault();

            if (c != null)
            {
                txtFolder.Text = string.IsNullOrEmpty(c.PathToWatch) ? Directory.GetCurrentDirectory() : c.PathToWatch;
                folderBrowserDialog1.SelectedPath = string.IsNullOrEmpty(c.PathToWatch) ? Directory.GetCurrentDirectory() : c.PathToWatch;
            }
        }
 private void btnSearchDirectory_Click(object sender, EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         var           folder = folderBrowserDialog1.SelectedPath;
         Configuration c      = DataManagerConf.read().FirstOrDefault();
         if (c == null)
         {
             c = new Configuration();
         }
         c.PathToWatch  = folder;
         txtFolder.Text = folder;
         List <Configuration> cc = new List <Configuration>();
         cc.Add(c);
         DataManagerConf.write(cc);
     }
 }
Beispiel #5
0
        private void btnMove_Click(object sender, EventArgs e)
        {
            Configuration c = DataManagerConf.read().FirstOrDefault();

            if (c == null)
            {
                c = new Configuration();
            }
            else
            {
                if (!string.IsNullOrEmpty(c.LastFolder))
                {
                    folderBrowserDialog1.SelectedPath = c.LastFolder;
                }
            }
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                move(folderBrowserDialog1.SelectedPath);
            }
        }
Beispiel #6
0
        private void startMonitor()
        {
            sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
            SystemEvents.SessionSwitch += sseh;
            DataManager.storeStartPresence(DateTime.Now);
            Configuration c = DataManagerConf.read().FirstOrDefault();

            if (c == null)
            {
                c             = new Configuration();
                c.PathToWatch = Directory.GetCurrentDirectory();
            }
            watcher              = new FileSystemWatcher();
            watcher.Path         = c.PathToWatch;
            watcher.NotifyFilter = NotifyFilters.LastWrite;

            /* NotifyFilters.LastAccess | NotifyFilters.LastWrite
             | NotifyFilters.FileName | NotifyFilters.DirectoryName;
             */
            watcher.Filter              = "*.*";
            watcher.Changed            += new FileSystemEventHandler(OnChanged);
            watcher.EnableRaisingEvents = true;
        }
Beispiel #7
0
        private void btnMoveToLast_Click(object sender, EventArgs e)
        {
            Configuration c = DataManagerConf.read().FirstOrDefault();

            move(c.LastFolder);
        }