Answers for "c# filesystemwatcher double events"

C#
0

c# filesystemwatcher double events

//Inside the OnChanged Method
void OnChanged(object source, FileSystemEventArgs e)
        {
            DateTime lastWriteTime = File.GetLastWriteTime(@"PathToCheck");
            if (lastWriteTime != lastRead)
            {
                if (File.Exists(destPath))
                {
                    File.Delete(destPath);
                }

                File.Move(sourcePath, destPath);
                lastRead = lastWriteTime;
            }
        }
Posted by: Guest on December-30-2019

C# Answers by Framework

Browse Popular Code Answers by Language