Inheritance: FileSystemEventArgs
 private  void OnRenamed(object source, RenamedEventArgs e)
 {
     
     int index = MakeReserve();
     writeLog(e.FullPath + " " + e.ChangeType + " <" + index + ">");
     Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
 }
Example #2
0
 private void OnRenamed(object source, RenamedEventArgs e)
 {
     // Specify what is done when a file is renamed.
     mainForm.addFileChange("File: " + e.OldFullPath + " renamed to " + e.FullPath);
     FileEvent fe = new FileEvent(++eventnum, e.ChangeType, e.FullPath, e.OldFullPath);
     proc.addevent(ref fe);
 }
Example #3
0
 private void OnRenamed(object sender, RenamedEventArgs e)
 {
     if (!m_bDirty)
     {
         m_bDirty = true;
     }
 }
Example #4
0
		private void fsWather_Renamed(object sender, RenamedEventArgs e)
		{
			if (Renamed != null)
			{
				Renamed(this, e);
			}
		}
 private void ProxyRename(object sender, RenamedEventArgs e)
 {
     if (e.Name.ToLowerInvariant() == _localFileName)
     {
         Reparse();
     }
 }
        void FileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
        {
            ListViewItem lvi = GetListViewItem(e.OldFullPath);

            if(lvi != null)
                ListViewItemCreator.SetListViewItemValues(lvi, GetFileSystemInfo(e.FullPath), this.exRepListView);
        }
Example #7
0
 public void ProcessActionItems(RenamedEventArgs e, FSEventType type)
 {
     foreach(FswatchRuleActionItem actionitem in this.__actionitems)
     {
         actionitem.InvokeAction(e, type);
     }
 }
Example #8
0
 void fsw_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     if (LogEvent != null)
     {
         LogEvent(Classes.Enumerations.LoggingEnumerations.LogEventTypes.Information, "File Renamed from " + e.OldFullPath + " to " + e.FullPath);
     }
 }
 private void Watcher_Renamed(object sender, RenamedEventArgs e)
 {
     var delete = new FileSystemEventArgs(WatcherChangeTypes.Deleted, Path.GetDirectoryName(e.OldFullPath), Path.GetFileName(e.OldName));
     var create = new FileSystemEventArgs(WatcherChangeTypes.Created, Path.GetDirectoryName(e.FullPath), Path.GetFileName(e.Name));
     queue.Enqueue(delete);
     queue.Enqueue(create);   
 }
Example #10
0
 private void FolderWatcherTest_Renamed(object sender, RenamedEventArgs e)
 {
     Invoke(new Action(() =>
     {
         listBox2.Items.Add("Renamed " + e.OldFullPath + " => " + e.FullPath + " " + sender.ToString());
     }));
 }
 public FileEventArgs(WatcherChangeTypes changeType, string fullname, string name, RenamedEventArgs renameArgs)
 {
     this.ChangeType = changeType;
     this.FullPath = fullname;
     this.Name = name;
     RenameName = renameArgs;
 }
Example #12
0
        private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            string[] str =
            {
                DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(),
                e.Name,
                "重命名",
                e.FullPath.ToString()
            };
            ListViewItem item = new ListViewItem(str);

            lvMonitor.Items.Add(item);

            file_Rename_count++;

            if (startSpeakCheck.Checked == true)
            {
                sendString = "重命名 " + e.Name.Substring(0, e.Name.LastIndexOf("."));
                if (speak_Thread == null)
                {
                    speak_Thread = new Thread(new ThreadStart(MonitorSpeak));
                    speak_Thread.Start();
                }
                else
                {
                    speak_Thread.Abort();
                    speak_Thread.Join();
                    speak_Thread = null;
                    speak_Thread = new Thread(new ThreadStart(MonitorSpeak));
                    speak_Thread.Start();
                }
            }
        }
Example #13
0
 private static void FileRenamed_Handler(object source, RenamedEventArgs e)
 {
     _countFileChangeEvent++;
     Console.WriteLine("FileEvent {0} : {1} - Old Path : {2} New Path : {3}",
         _countFileChangeEvent.ToString("#00"), e.ChangeType, e.OldFullPath, e.FullPath);
     m_timer.Change(TimeoutMillis, System.Threading.Timeout.Infinite);
 }
Example #14
0
 private static void OnRenamed(object source, RenamedEventArgs e)
 {
     var o = e.OldName;
     var n = e.Name;
     LogRepo.Create(Timestamp.Now, e.ChangeType.ToString(), e.FullPath, e.OldName);
     ConsoleLogger.Log(Timestamp.Now + " File: {0} renamed to {1}", o, n);
 }
 private void OnRenamedInternal(object sender, RenamedEventArgs e)
 {
     _logger.Info("Config file renamed from " + e.OldFullPath + " to " + e.FullPath);
     DirectoryToMonitor = e.FullPath;
     _changeMonitor.Filter = Path.GetFileName(e.FullPath);
     ConfigRenamed(e.OldFullPath, e.FullPath);
 }
        private void BranchWatcher_Renamed(object sender, RenamedEventArgs e)
        {
            if (!string.Equals(e.Name, "branch", StringComparison.InvariantCultureIgnoreCase))
                return;

            RequestCurrentBadgeRefresh();
        }
        private async void Renamed(RenamedEventArgs renamedEventArgument, Func<string, bool, Task> updateBundle)
        {
            using (await rwLock.ReadLockAsync())
            {
                if (!_watchedFiles.ContainsKey(renamedEventArgument.OldFullPath) ||
                    !renamedEventArgument.FullPath.StartsWith(ProjectHelpers.GetSolutionFolderPath(), StringComparison.OrdinalIgnoreCase))
                    return;
            }

            HashSet<Tuple<string, FileSystemWatcher>> oldValue;

            using (await rwLock.ReadLockAsync())
            {
                oldValue = _watchedFiles[renamedEventArgument.OldFullPath];
            }

            using (await rwLock.WriteLockAsync())
            {
                _watchedFiles.Remove(renamedEventArgument.OldFullPath);
            }

            _document = await _document.LoadFromFile(renamedEventArgument.FullPath);

            foreach (Tuple<string, FileSystemWatcher> tuple in oldValue)
            {
                tuple.Item2.EnableRaisingEvents = false;

                tuple.Item2.Dispose();

                if (_extensions.Any(e => tuple.Item1.EndsWith(e, StringComparison.OrdinalIgnoreCase)))
                    await AttachFileObserver(_document, _document.FileName, updateBundle);
                else
                    await AttachFileObserver(_document, tuple.Item1, updateBundle);
            }
        }
Example #18
0
        public void RenameFile(System.IO.RenamedEventArgs e)
        {
            MyTimer.Stop();

            try
            {
                string strOldSourceFileName = Path.GetFileName(e.OldFullPath);

                string strSourceFileName = Path.GetFileName(e.FullPath);
                bool   exists            = System.IO.Directory.Exists(e.OldFullPath);

                string strSourceFile  = $@"{DstRoot}\\{strOldSourceFileName}";
                string strDesFilePath = $@"{DstRoot}\\{strSourceFileName}";

                if (exists)
                {
                    Directory.Move(strSourceFile, strDesFilePath);
                }
                else
                {
                    File.Move(strSourceFile, strDesFilePath);
                }
            }
            catch (Exception ioe)
            {
                _eventLog.WriteEntry("FileSync Rename File failed: " + ioe.Message);
            }

            MyTimer.Start();
        }
Example #19
0
        /// <summary>
        /// Обработчик события переименования папки
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void Rename(object sender, RenamedEventArgs e)
        {
            Model.Dir dir = Model.Dir.FindByPath(e.OldFullPath);
            dir.RenameOnServer(e.FullPath);

            Helpers.ApplicationHelper.SetCurrentTimeToSettings();
        }
        private static void OnRenamed(object source, RenamedEventArgs e)
        {
            // Specify what is done when a file is renamed.
            ////console.WriteLine("File: {0} renamed to {1} ", e.OldFullPath, e.FullPath);

            //console.WriteLine("File: {0} {1} to {2} and FileName: {3} finally, Old File Name: {4}", e.OldFullPath, e.ChangeType, e.FullPath, e.Name, e.OldName);

            DataStore.Filenode toBeQueueNode = new DataStore.Filenode();
            toBeQueueNode.setNewPath(e.FullPath);
            toBeQueueNode.setAction(e.ChangeType.ToString());
            toBeQueueNode.setOldPath(e.OldFullPath);
            toBeQueueNode.setCloudDestinationPath(null); //indetermined, requires modification

            /*try
            {
                FileInfo oldfileinfo = new FileInfo(e.OldFullPath);
                FileInfo newfileinfo = new FileInfo(e.FullPath);

                oldfileinfo.Refresh();
                //console.WriteLine("Old File LastWriteTime" + oldfileinfo.LastWriteTime);
                newfileinfo.Refresh();
                //console.WriteLine("New File lastWriteTime" + newfileinfo.LastWriteTime);

                if (oldfileinfo.Exists)
                {
                    //console.WriteLine("Old File Length in Bytes: " + oldfileinfo.Length);
                }

                if (newfileinfo.Exists)
                {
                    //console.WriteLine("New File Length in Bytes: " + newfileinfo.Length);
                }

                if (oldfileinfo.LastWriteTime.CompareTo(newfileinfo.LastWriteTime) < 0)
                {
                    //console.WriteLine("New File Info has later modification time");
                }
                else if (oldfileinfo.LastWriteTime.CompareTo(newfileinfo.LastWriteTime) > 0)
                {
                    //console.WriteLine("Old File Info has later modification time");
                }
                else
                {
                    //they are the same
                    //console.WriteLine("Same Modification Time");
                }

            }
            catch (Exception ex)
            {
                //exception thrown
                //console.WriteLine("Length Write Time Exception");
            }*/

            if (Entry.Entry.checkWave(e.Name) || Entry.Entry.checkTmp(e.Name))
                return;

               Entry.Entry.fileQueue.Enqueue(toBeQueueNode);
        }
Example #21
0
 void fsw_Renamed(object sender, RenamedEventArgs e)
 {
     txtActivity.Invoke(
     (MethodInvoker)delegate {
     txtActivity.AppendText(e.ChangeType.ToString() + " : " + e.Name + "\n");
       }
       );
 }
Example #22
0
        private void OnRenamed(object source, RenamedEventArgs e)
        {

            // Specify what is done when a file is renamed.
            ReaderFileWip22();
            ReaderFileWip23();
            ReaderFileWip21();
        }
        private void watcherRenamed(object sender, System.IO.RenamedEventArgs e)
        {
            eventLog1.WriteEntry("Renamed file " + e.OldFullPath + " to " + e.FullPath, System.Diagnostics.EventLogEntryType.Information);
#if (DEBUG)
            System.Console.WriteLine("Renamed file " + e.OldFullPath + " to " + e.FullPath);
#endif
            this.SendObject(new Packet(getCurrentUser(), System.DateTime.Now, e.FullPath, e.OldFullPath, GetFileHash(e.FullPath), WatcherInfoType.FILE_RENAMED));
        }
Example #24
0
 private void BufferRenameEvent(object _, RenamedEventArgs e)
 {
     if (!_fileSystemEventBuffer.TryAdd(e))
     {
         var ex = new EventQueueOverflowException($"Event queue size {_fileSystemEventBuffer.BoundedCapacity} events exceeded.");
         InvokeHandler(_onErrorHandler, new ErrorEventArgs(ex));
     }
 }
 private void FS_DirRenamed(object sender, System.IO.RenamedEventArgs e)
 {
     lock (FSEventListLock)
     {
         FSEventListAnalysisTimer.Enabled = false;
         FSEventList.Add(new FSSyncEvent(BasicActionEnum.DirRenamed, e.OldFullPath, e.FullPath));
         FSEventListAnalysisTimer.Enabled = true;
     }
 }
 private void FS_FileRenamed(object sender, System.IO.RenamedEventArgs e)
 {
     lock (FSEventListLock)
     {
         FSEventListAnalysisTimer.Enabled = false; //Stop Timer so that the analysing event will only occur when the system is idle (ie when all changes have been performed)
         FSEventList.Add(new FSSyncEvent(BasicActionEnum.FileRenamed, e.OldFullPath, e.FullPath));
         FSEventListAnalysisTimer.Enabled = true;
     }
 }
Example #27
0
File: Runner.cs Project: vjorjo/fs
		private void OnRenameNotification(object sender, RenamedEventArgs e)
		{
		    FileSystemWatcher w = (FileSystemWatcher)sender;
		    HandleNotification(w, e, () =>
		    {
		        Output(Console.Out, _args.Format, w, Change.MOVED_FROM, e.OldName);
		        Output(Console.Out, _args.Format, w, Change.MOVED_TO, e.Name);
		    });
		}
 private static void OnRenamed(object source, RenamedEventArgs e) {
     try {
         hostsWatcher.EnableRaisingEvents = false;
         Thread.Sleep(2000); //nötig um sicher zu stellen, dass schreibende Zugriff abgeschlossen ist 
         InstallBlockList.Blocker(Service1.hostsFile, Service1.newHostsFile);
     } finally {
         hostsWatcher.EnableRaisingEvents = true;
     }
 }
Example #29
0
 void _actualWatcher_Renamed(object sender, RenamedEventArgs e)
 {
     _actualWatcher.EnableRaisingEvents = false;
     var oldFile = (File)e.OldFullPath;
     NotifySubscribers(FileChange.Deleted, oldFile);
     var file = (File)e.FullPath;
     NotifySubscribers(FileChange.Added, file);
     _actualWatcher.EnableRaisingEvents = true;
 }
Example #30
0
 private static void OnRenamed(object source, RenamedEventArgs ev)
 {
     ProcessChangeOnlyOnce(ev, e =>
     {
         ConsoleWriteLineSeparator();
         Console.WriteLine("RENAMED to: \"{0}\"", RelativePath(e.FullPath));
         ProcessChange(e.FullPath);
     });
 }
Example #31
0
        private void FileRenamed(System.Object sender, System.IO.RenamedEventArgs e)
        {
            if (DebugOutput)
            {
                Logger.Log.Info("Renamed watcher event: " + e.OldFullPath + " " + e.FullPath);
            }

            fileWatcherQueue.EventItems.Add(e);
        }
Example #32
0
 public bool ProcessMatchItems(RenamedEventArgs e, FSEventType type)
 {
     foreach(FswatchRuleMatchItem matchitem in this.__matchitems)
     {
         bool result = matchitem.MatchCondition(e, type);
         if(!result)
             return false;
     }
     return true;
 }
Example #33
0
        private static void OnRenamed(object source, RenamedEventArgs e)
        {
            // Specify what is done when a file is renamed.
            string strFileExt = Path.GetExtension(e.FullPath);

            if (strFileExt == ".docx" || strFileExt == ".doc")
            {
                Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
            }
        }
Example #34
0
	    private void HandleRenameFileSystemEvent(RenamedEventArgs a)
	    {
	        Initialize();

            var fileInfoOld = FileInfo.Create(GetRootPath(PathInfo.GetSubPath(_basePath, a.OldFullPath)));
            var fileInfo = FileInfo.Create(GetRootPath(PathInfo.GetSubPath(_basePath, a.FullPath)));

            NotifySubscriptions(new FileChangeEventArgs(fileInfoOld, FileChangeType.Deleted));
            NotifySubscriptions(new FileChangeEventArgs(fileInfo, FileChangeType.Created));
        }
Example #35
0
 private void OnRenamed(object sender, RenamedEventArgs e)
 {
     if (e.FullPath.EndsWith(".sending"))
         return;
     SetResult(new FileWatcherFile
     {
         EndPoint = _watcher.Path,
         Paths = new[] { e.FullPath },
         Error = FileWatcherError.Success,
     });
 }
 private void ProxyRename(object sender, RenamedEventArgs e)
 {
     if (e.Name.ToLowerInvariant() == _localFileName)
     {
         Reparse();
     }
     else if(e.OldName.ToLowerInvariant() == _localFileName)
     {
         _fileDeletedCallback(sender, e);
     }
 }
        private void fileSystemWatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            string sLog = Convert.ToString(DateTime.Now) + " | " + e.ChangeType + " | " + e.FullPath + Environment.NewLine;

            AppendText(sLog);
            StreamWriter sw = File.AppendText(strWorkPath);

            sw.WriteLine(e.ChangeType + "|" + e.OldFullPath + " to " + e.FullPath + "|" + DateTime.Now.ToLongTimeString());
            sw.Flush();
            sw.Close();
        }
Example #38
0
 protected void Renamed(object source, RenamedEventArgs e)
 {
     if (Directory.Exists(e.FullPath)) {
         RemoveDirectory(new DirectoryInfo(e.OldFullPath));
         SetDirectory(new DirectoryInfo(e.FullPath));
     } else {
         RemoveFile(new FileInfo(e.OldFullPath));
         SetFile(new FileInfo(e.FullPath));
     }
     Handler.Change();
 }
 private void RenamedItem(object source, RenamedEventArgs e)
 {
     whatHappened =e.OldName + " was renamed to " + e.Name;
     DirectoryInfo s = new DirectoryInfo(address);
     FileInfo[] items = s.GetFiles("*." + ending);
     Files.Clear();
     for (int i = 0; i < items.Count(); i++)
     {
         FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
         Files.Add(newFile);
     }
 }
Example #40
0
        private static void FileSystemWatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            try
            {
                CallFileChange(e.OldName, e.Name);
            }

            catch (Exception ex)
            {
                Common.Logger.Error("监视文件改变出错。", ex);
            }
        }
        private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            string renamed = e.Name;
            string oldName = e.OldName;

            string LogEvent;

            LogEvent = "The file " + oldName + " has been renamed to "
                       + renamed + " at " + DateTime.Now + ".";

            LogIt(new string[] { LogEvent });
        }
Example #42
0
        private void Filereader(object sender, System.IO.RenamedEventArgs e)
        {
            string[] Filename = Directory.GetFiles(@"C:\Users\Miguel\Desktop\BatchFiles");

            if (System.IO.File.Exists(@"C:\Users\Miguel\Desktop\BatchFiles"))
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName         = Filename.ToString();
                proc.StartInfo.WorkingDirectory = Filename.ToString();
                proc.Start();
            }
        }
 private void Watcher_SarifLogFileRenamed(object sender, System.IO.RenamedEventArgs e)
 {
     /*
      * When updating a file in VS, it saves file content to a new temp file and rename current file to another temp file,
      * then rename 1st temp file with latest content to current file name and delete 2nd temp file.
      * Here we need to catch the event the 1st temp file is renamed to current file name
      * and ignore event current file is renamed to 2nd temp file.
      */
     if (FileWatcherMap.ContainsKey(e.FullPath))
     {
         this.RefreshSarifErrors(e.FullPath);
     }
 }
Example #44
0
        /// <summary>
        /// Event handler when a file is renamed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventargs"></param>
        private void File_Renamed(object sender, System.IO.RenamedEventArgs eventargs)
        {
            string filepath    = eventargs.FullPath;
            string oldfilepath = eventargs.OldFullPath;
            string changetype  = eventargs.ChangeType.ToString();

            StringBuilder message = new StringBuilder();

            message.Append("File: " + oldfilepath + "  " + changetype + " to " + filepath);

            log.Write(message.ToString(), 2003, System.Diagnostics.EventLogEntryType.Warning);
            // Do any action specified for the file that was renamed
            DoAction(filepath, oldfilepath, changetype);
        }
Example #45
0
 private void InvokeHandler(RenamedEventHandler eventHandler, RenamedEventArgs e)
 {
     if (eventHandler != null)
     {
         if (_containedFSW.SynchronizingObject != null && this._containedFSW.SynchronizingObject.InvokeRequired)
         {
             _containedFSW.SynchronizingObject.BeginInvoke(eventHandler, new object[] { this, e });
         }
         else
         {
             eventHandler(this, e);
         }
     }
 }
Example #46
0
        /// <summary>
        /// FileSystemWatcher.Renamed イベント ハンドラー。
        /// 内部的に、onRenamedOrCreateOrDelete メソッドを実行している。
        /// </summary>
        /// <param name="sender">イベントの発生元 (FileSystemWatcher)</param>
        /// <param name="e">イベント発生元からの引数</param>
        private void fswRenamedHandler(Object sender, System.IO.RenamedEventArgs e)
        {
            bool isNewTarget = e.Name.ToLower().EndsWith(TvProgramWatcher.FILE_EXT);
            bool isOldTarget = e.OldName.ToLower().EndsWith(TvProgramWatcher.FILE_EXT);

            if (!isNewTarget && !isOldTarget)
            {
                return;
            }

            lock (lockTarget)
            {
                onRenamedOrCreateOrDelete(sender, e, isNewTarget, isOldTarget);
            }
        }
Example #47
0
        void fsw_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            if (paused)
            {
                return;
            }
            Console.WriteLine("Renamed: FileName - {0}, ChangeType - {1}, Old FileName - {2}", e.Name, e.ChangeType, e.OldName);

            GCAction a = new GCAction();

            a.Action  = GCAction.RENAMED;
            a.Path    = e.FullPath;
            a.OldPath = e.OldFullPath;
            db.Insert(a);
        }
        private void fswfoldercrawler_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            txtlog.Text += e.ChangeType + ": " + e.OldFullPath + " renamed to: " + e.FullPath + "\r\n";
            txtlog.Focus();
            txtlog.Select(txtlog.TextLength, 0);
            FileInfo ofi = new FileInfo(e.OldFullPath);
            FileInfo nfi = new FileInfo(e.FullPath);
            DBInfo   dbi = new DBInfo(nfi.Name, Path.GetDirectoryName(nfi.FullName), nfi.Extension, nfi.LastWriteTime.ToString());
            string   sql = "UPDATE files SET fn = '" + nfi.Name + "' WHERE fn = '" + ofi.Name + "'";

            indexing(sql);
            wci.renamed        += 1;
            lblrenamed.Text     = "Renamed: " + wci.renamed;
            lblLastIndexed.Text = "LastIndexed: " + dbi.fn;
            txtlog.ScrollToCaret();
        }
Example #49
0
 public void Watch_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     lock (_objlock)
     {
         if (IsHaveType(e.FullPath))
         {
             ListViewItem lvi = new ListViewItem();
             lvi.SubItems[0].Text = e.FullPath;
             Watch_FindMuma(e.FullPath, lvi, String.Format("重命名,重命名时间:{0}", DateTime.Now));
             lvi.SubItems.Add(String.Format("新名称:{0},原来名称:{1}", e.Name, e.OldName));
             AddItemToWatchList(lvi);
             string tipsMsg = "检视文件时发现有人重命名了文件,请管理员检查情况!";
             BLL.EmailQueue.Instance.AddEmailToDB(tipsMsg, string.Format("{0},发生时间为:{1},服务器IP:{2}", tipsMsg, DateTime.Now, Utils.GetIPAddress()));
         }
     }
 }
Example #50
0
        private void fsw_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            OnRenamed(e);
            string filepath = Path.GetDirectoryName(e.FullPath);
            string fileext  = Path.GetExtension(e.FullPath);
            title  oTitle   = FindTitle(e.FullPath);

            if (oTitle != null)
            {
                oTitle.Filename = e.FullPath;
                if (oTitle.Title == Path.GetFileNameWithoutExtension(e.OldFullPath))
                {
                    oTitle.Title = Path.GetFileNameWithoutExtension(e.FullPath);
                }
            }
            SaveTitles();
        }
Example #51
0
        private async void Watcher_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Renamed)
            {
                if (CheckExclusion(e.FullPath))
                {
                    return;
                }
                SetNotifyIcon(true);
                await Task.Run(delegate
                {
                    //Subtract the root directory from the full path and then add it to the outputDir
                    var fp = e.OldFullPath;
                    //new full path
                    var nfp = e.FullPath;
                    //Substring the rootDir?
                    var relativePath = fp.Substring(rootDir.Length);
                    //new relative path
                    var nRelativePath = nfp.Substring(rootDir.Length);
                    //Add this to outputDir for calculating final path
                    var finalPath = Path.GetFullPath(outputDir + "\\" + relativePath);
                    //New final path
                    var nFinalPath = Path.GetFullPath(outputDir + "\\" + nRelativePath);
                    //Now, let's rename
                    if (Directory.Exists(finalPath))
                    {
                        //Rename the directory
                        Directory.Move(finalPath, nFinalPath);
                    }
                    else if (File.Exists(finalPath))
                    {
                        //Move the file with new name. These events are not really handled well because these
                        //files might already be in use, and moving them won't work.
                        try
                        {
                            File.Move(finalPath, nFinalPath);
                        }
                        catch
                        {
                        }
                    }
                });

                SetNotifyIcon(false);
            }
        }
Example #52
0
            private void OnRenamed(object sender, System.IO.RenamedEventArgs e)
            {
                lock (_lock)
                {
                    if (IsSuspended)
                    {
                        return;
                    }

                    if (MatchDeleted(e.OldFullPath) && TryUnregisterMatchingPath(e.OldFullPath))
                    {
                        NotifyDeleted(e.OldFullPath, newPath: e.FullPath);
                    }
                    else if (MatchCreated(e.FullPath) && TryRegisterMatchingPath(e.FullPath))
                    {
                        NotifyCreated(e.FullPath, oldPath: e.OldFullPath);
                    }
                }
            }
Example #53
0
 /// <summary>
 /// 更新列表
 /// </summary>
 protected void refreshListFSE(System.IO.RenamedEventArgs re)
 {
     listView_syncStatus.Invoke(new MethodInvoker(delegate
     {
         if (User_LocalInfo == null)
         {
             return;
         }
         string itemText = (@"Home:\" + Path.GetFullPath(re.OldFullPath).Substring(Path.GetFullPath(User_LocalInfo.SyncPath).Length));
         if (!listView_syncStatus.Items.ContainsKey(itemText))
         {
             return;
         }
         listView_syncStatus.Items[itemText].SubItems[1].Text      = re.ChangeType.ToString();
         listView_syncStatus.Items[itemText].SubItems[2].Text      = "正在检测";
         listView_syncStatus.Items[itemText].SubItems[2].ForeColor = Color.Blue;
         listView_syncStatus.Items[itemText].Text = (@"Home:\" + Path.GetFullPath(re.FullPath).Substring(Path.GetFullPath(User_LocalInfo.SyncPath).Length));
         listView_syncStatus.Items[itemText].Name = listView_syncStatus.Items[itemText].Text;
     }));
 }
Example #54
0
        private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            try
            {
                // Sending post to web api
                using (var httpClient = new HttpClient())
                {
                    var watchRecord = new WatchRecord();
                    watchRecord.Path = e.FullPath;


                    // get the file attributes for file or directory
                    FileAttributes attr = File.GetAttributes(e.FullPath);
                    if (attr.HasFlag(FileAttributes.Directory))
                    {
                        //MessageBox.Show("Its a directory");
                        watchRecord.IsFile = false;
                    }
                    else
                    {
                        //MessageBox.Show("Its a file");
                        watchRecord.IsFile = true;
                    }

                    watchRecord.Event = e.ChangeType.ToString();
                    watchRecord.Date  = DateTime.Now;

                    var result = JsonConvert.SerializeObject(watchRecord);
                    httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var response = Task.Run(() => httpClient.PostAsync("http://vysoft.somee.com/api/WatchRecords", new StringContent(result, Encoding.UTF8, "application/json")));

                    //var responseString = response.Result.RequestMessage;
                    //Console.WriteLine(responseString);
                }
            }
            catch
            {
            }
        }
Example #55
0
        void OnPhotoRenamed(object sender, System.IO.RenamedEventArgs e)
        {
            int index = -1;

            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i].FullPath == e.OldFullPath)
                {
                    index = i;
                    break;
                }
            }
            if (index >= 0)
            {
                Items[index] = new Photo(e.FullPath);
            }

            if (ItemsUpdated != null)
            {
                ItemsUpdated(this, new EventArgs());
            }
        }
Example #56
0
        void ZmienionaNazwaZdjecia(object sender, System.IO.RenamedEventArgs e)
        {
            int index = -1;

            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i].PelnaSciezka == e.OldFullPath)
                {
                    index = i;
                    break;
                }
            }
            if (index >= 0)
            {
                Items[index] = new Zdjecie(e.FullPath);
            }

            if (ItemsUpdated != null)
            {
                ItemsUpdated(this, new EventArgs());
            }
        }
Example #57
0
 private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     try
     {
         fileSystemWatcher1.EnableRaisingEvents = false;
         var split  = e.Name.Split('\\');
         var second = split[1];
         var last   = split[split.Length - 1];
         if (second == "SavedVariables" && last == "CensusPlusClassic.lua")
         {
             long size = new FileInfo(e.FullPath).Length;
             if (size > 3145728)
             {
                 MessageBox.Show("Your CensusPlusClassic.lua is greater than 3 MB. Please consider using the prune/purge button within the addon.", "CensusUploader", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             uploadCensus(e.FullPath);
         }
     }
     finally
     {
         fileSystemWatcher1.EnableRaisingEvents = true;
     }
 }
Example #58
0
 private void FileSystemWatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     addFileSystemEvent(e);
 }
Example #59
0
 private void fileSystemWatcherMain_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     logger.Info("Renamed: " + e.FullPath);
 }
Example #60
0
 void fileSystemWatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     DisplayFileSystemWatcherInfo(e.ChangeType, e.Name, e.OldName);
 }