Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fs.watch blocks folder (windows 8) #3963

Closed
ArtemGovorov opened this Issue · 5 comments

3 participants

Artem Govorov Ben Noordhuis Bert Belder
Artem Govorov

On windows 8 running following code

require('fs').watch('C:/Test');
require('fs').watch('C:/Test/Sub/SubSub');

and trying to rename C:/Test/Sub causes error:

Folder In Use The action can't be completed because the folder or a file in it is open in another program

Ben Noordhuis

That's a limitation of the Windows file watcher API. Use fs.watchFile() if you don't want that.

Ben Noordhuis bnoordhuis closed this
Bert Belder
Owner

I wish we would be able to work around this, but unfortunately we can't.

Artem Govorov

System.IO.FileSystemWatcher in .NET uses the same API (ReadDirectoryChangesW) and it works for given scenario. Could you elaborate please why is that impossible?

Bert Belder
Owner

ReadDirectoryChangesW (apparently) locks the parent folder of the folder being watched.

You can even replicate this with windows explorer.

  • Create folder c:\a\b
  • Open that folder in windows explorer
  • Try to rename c:\a

System.IO.FileSystemWatcher in .NET uses the same API (ReadDirectoryChangesW) and it works for given scenario.

I don't believe you. Convince me by sharing your test case :-)

Artem Govorov

Windows explorer actually works fine on Windows 7-8, opened sub-folder explorer just updates the path. Though I can replicate what you're talking about on XP.

Regarding FileSystemWatcher, you're right, I tried to set up some basic test and realised that it does also block parent folder of the folder being watched. Thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.