Why is my PowerShell FileSystemWatcher sometimes failing to copy files?

0
0
Asked By CuriousCat123 On

Hey everyone! I've been working on a Powershell project to create a sort of in-game selfie kiosk with two computers running different games. The setup involves monitoring screenshot folders to copy images automatically, display them in a slideshow, and print them using a photo printer.

I've set up multiple FileSystemWatcher instances to watch these folders, but I'm running into a problem. Specifically, the action that moves screenshots from the Cyberpunk folder to designated folders only works inconsistently—while the other parts of the script run without fail. I've shared the code snippet I'm using, and I'm really hoping someone can help me find a workaround as I'm under time pressure. Thanks in advance!

1 Answer

Answered By TechyTurtle42 On

I see where you’re coming from! Instead of managing multiple event handlers individually, consider combining your scripts into fewer handlers to handle similar actions. Sometimes order isn’t guaranteed when you add several handlers, which might lead to the inconsistencies you're experiencing. Give that a shot and see if it helps!

CuriousCat123 -

Thanks for the tip! I did combine the handlers, but the issue persists. What do you think about replacing multiple "Register-ObjectEvent" commands with a single "Wait-Event"? Could that simplify things?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.