Exemple #1
0
        public void ManuallyTriggerFileChange(FileInformation changedFile,
                                              FileChangeNotification.FileChangeType changeType)
        {
            var _ = new FileTrackChangesRequest(); // manually triggered change notification does not have a calling message.

            _connection.SendMessage(new FileChangeNotification(_, changedFile, changeType));
        }
Exemple #2
0
        private void handleTrackChangesRequest(FileTrackChangesRequest tcr)
        {
            if (_trackChangesRequest == null) // first time
            {
                _trackChangesRequest = tcr;
                var fsv = new FileSystemWatcher(_rootDir);
                fsv.NotifyFilter        = NotifyFilters.FileName | NotifyFilters.Size;
                fsv.EnableRaisingEvents = true;
                fsv.Created            += (s, fArg) =>
                {
                    _connection.SendMessage(new FileChangeNotification(_trackChangesRequest,
                                                                       new FileInformation(_rootDir, fArg.Name), FileChangeNotification.FileChangeType.Created));
                };

                fsv.Deleted += (s, fArg) =>
                {
                    _connection.SendMessage(new FileChangeNotification(_trackChangesRequest,
                                                                       new FileInformation(_rootDir, fArg.Name), FileChangeNotification.FileChangeType.Deleted));
                };

                fsv.Changed += (s, fArg) => // TODO: fix this, it does not work well. https://stackoverflow.com/questions/22447022/best-way-to-track-files-being-moved-possibly-between-disks-vb-net-or-c
                {
                    _connection.SendMessage(new FileChangeNotification(_trackChangesRequest,
                                                                       new FileInformation(_rootDir, fArg.Name), FileChangeNotification.FileChangeType.Modified));
                };
            }

            _trackChangesRequest = tcr;
        }
 public FileChangeNotification(FileTrackChangesRequest request, FileInformation file, FileChangeType changeType)
     : base(request)
 {
     ModifiedFile = file;
     ChangeType   = changeType;
 }