private void ProcessFileSystemChange(FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Changed && Directory.Exists(e.FullPath))
                return;

            if (string.Equals(Path.GetExtension(e.Name), ".lock", StringComparison.OrdinalIgnoreCase))
                return;

            MarkDirty(true);
        }
Ejemplo n.º 2
0
 private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     EventLog.WriteEntry("NadzornikServis: " + e.FullPath + " " + e.ChangeType.ToString());
 }
Ejemplo n.º 3
0
 private void watcher_Created(object sender, System.IO.FileSystemEventArgs e)
 {
     RefreshResumeDat();
 }
Ejemplo n.º 4
0
 private void RaisePopulateFlag(object sender, System.IO.FileSystemEventArgs e)
 {
     fireEvent = true;
 }
Ejemplo n.º 5
0
 private void RaisePopulateFlag(object sender, System.IO.FileSystemEventArgs e)
 {
     // Signal the main thread it's time to populate (cannot run populate somewhere else than on main thread)
     fireEvent = true;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// The event that is raised when a new file is created in the control dir
        /// </summary>
        /// <param name="sender">The event sender</param>
        /// <param name="e">The file event arguments</param>
        private void m_filewatcher_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            //Retry 5 times if the other process is slow on releasing the file lock
            int retrycount = 5;

            //Indicator and holder of arguments passed
            string[] commandline = null;

            //HACK: Linux has some locking issues
            //The problem is that there is no atomic open-and-lock operation, so the other process
            // needs a little time to create+lock the file. This is not really a fix, but an
            // ugly workaround. This functionality is only used to allow a new instance to signal
            // the running instance, so errors here would only affect that functionality
            if (Library.Utility.Utility.IsClientLinux)
            {
                System.Threading.Thread.Sleep(1000);
            }

            do
            {
                try
                {
                    //If the other process deleted the file, just quit
                    if (!System.IO.File.Exists(e.FullPath))
                    {
                        return;
                    }

                    List <string> args = new List <string>();
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(Duplicati.Library.Utility.Utility.IsClientLinux ? UnixSupport.File.OpenExclusive(e.FullPath, System.IO.FileAccess.ReadWrite) : new System.IO.FileStream(e.FullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None)))
                        while (!sr.EndOfStream)
                        {
                            args.Add(sr.ReadLine());
                        }

                    commandline = args.ToArray();

                    //Remove the file to notify the other process that we have correctly processed the call
                    System.IO.File.Delete(e.FullPath);
                }
                catch
                {
                }

                //If file-reading failed, wait a little before retry
                if (commandline == null)
                {
                    System.Threading.Thread.Sleep(500);
                    retrycount--;
                }
            } while (retrycount > 0 && commandline == null);

            //If this happens, we detected the file, but was unable to read it's contents
            if (commandline == null)
            {
                //There is nothing we can do :(
            }
            else
            {
                //If we read the data but did not delete the file, the other end still hangs
                //and waits for us to clean up, so try again.
                retrycount = 5;
                while (retrycount > 0 && System.IO.File.Exists(e.FullPath))
                {
                    try
                    {
                        System.IO.File.Delete(e.FullPath);
                    }
                    catch
                    {
                        //Wait before the retry
                        System.Threading.Thread.Sleep(500);
                    }

                    retrycount--;
                }

                //If this happens, the other process will give an error message
                if (System.IO.File.Exists(e.FullPath))
                {
                    //There is nothing we can do :(
                }

                //Finally inform this instance about the call
                if (SecondInstanceDetected != null)
                {
                    SecondInstanceDetected(commandline);
                }
            }
        }
Ejemplo n.º 7
0
 private static void W_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     Console.WriteLine(e.Name);
 }
Ejemplo n.º 8
0
 private void OnFileCreated(object sender, System.IO.FileSystemEventArgs e) => _created?.Invoke(this, e);
Ejemplo n.º 9
0
 protected void mainFileSystemWatcherChanged(object sender, System.IO.FileSystemEventArgs e)
 {
 }
Ejemplo n.º 10
0
 void myWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     Console.WriteLine(String.Format("myWatcher_Changed : {0}, changed : {1}, name : {2}", e.FullPath, e.ChangeType, e.Name));
 }
Ejemplo n.º 11
0
 private static void Fsw_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     Console.WriteLine("Filen {0} er rettet", e.Name);
 }
Ejemplo n.º 12
0
 private static void Fsw_Created1(object sender, System.IO.FileSystemEventArgs e)
 {
     Console.WriteLine("A second subscriber");
 }
 private void _DirectoryWatch_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     //read the file and send to the server
     ReadAllRecords();
     return;
 }
 private void FileSystemWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     CambiarBotonRefrescar(false);
     ActualizarDatos();
 }
 private void HandleFileSystemChanged(object sender, FileSystemEventArgs e)
 {
     Action action = () => ProcessFileSystemChange(e);
     Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, SccProviderService.TaskScheduler)
         .HandleNonCriticalExceptions();
 }
Ejemplo n.º 16
0
 void OnChanged(object source, System.IO.FileSystemEventArgs e)
 {
     ReadConfig();
 }
Ejemplo n.º 17
0
 protected void OnDeleted(System.IO.FileSystemEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 private static void W_Created(object sender, System.IO.FileSystemEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 19
0
 private static void OnChange(object sender, System.IO.FileSystemEventArgs e)
 {
     System.Console.WriteLine(e.FullPath.ToString() + " is changed!");
 }
Ejemplo n.º 20
0
        public OperationResult DoAction(string path, Dictionary <string, string> parameters, System.IO.FileSystemEventArgs modificationArg)
        {
            if (!parameters.ContainsKey("command"))
            {
                return(OperationResult.InvalidArgument);
            }

            Process pocess = new Process();

            pocess.StartInfo.FileName  = "%windir%\\System32\\cmd.exe";
            pocess.StartInfo.Arguments = String.Format("/c \"{0}\"", parameters["command"].Replace("$TARGET_FILE$", modificationArg.FullPath));

            pocess.Start();

            return(OperationResult.Success);
        }
Ejemplo n.º 21
0
 private void watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     Logger.Trace("Restarted delay timer");
     mScanDelayTimer.Stop();
     mScanDelayTimer.Start();
 }
Ejemplo n.º 22
0
 private static void W_Created(object sender, System.IO.FileSystemEventArgs e)
 {
     Console.WriteLine("Filen " + e.Name + " er oprettet");
 }
Ejemplo n.º 23
0
 private void fileSystemWatcherMessages_Changed(object sender, System.IO.FileSystemEventArgs e) //Refreshes messages when a new msg.msgusr is downloaded via MessageCheck().
 {
     refreshMessages();
     System.Threading.Thread.Sleep(30);
     Console.WriteLine("Refreshing messages!");
 }
Ejemplo n.º 24
0
 private void SaveDirectoryFileSystemWatcher_Deleted(object sender, System.IO.FileSystemEventArgs e)
 {
     DrawTestPanels();
 }
Ejemplo n.º 25
0
 private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     FileSys.Refresh();
     DisplayDirs();
 }
Ejemplo n.º 26
0
 private static void Fsw_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     Console.WriteLine($"File \"{e.Name}\" was modified");
 }
        private static void MkvFileCreated(object sender, System.IO.FileSystemEventArgs e)
        {
            VideoFile video = VideoFactory.CreateVideoFile(sender, e);

            SaveVideoToDb(video);
        }
Ejemplo n.º 28
0
 private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
 }
 // I have several types of events that can come in,
 // they just get packaged up into the same "SensorData"
 // struct, and I worry about the contents later
 private void FileSystem_Changed( object sender, System.IO.FileSystemEventArgs e )
 {
     EnqueueSensorEvent(new SensorData(sender, e));
 }
 private void OnChanged(object source, FileSystemEventArgs e)
 {
     string fullpath = e.FullPath.Replace('\\', '/');
     fileSet[fullpath] = locationRoot;
 }
Ejemplo n.º 31
0
 protected void OnCreated(System.IO.FileSystemEventArgs e)
 {
 }
Ejemplo n.º 32
0
 protected void OnDeleted(System.IO.FileSystemEventArgs e)
 {
 }
Ejemplo n.º 33
0
 void m_FileWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     OnFileChanged();
 }