My vb macro monitors the folder path for new file creation.I can able to monitor the paths in local drive.
How to provide the path for network drive???
here is my code below.here strDirToMonitor is the place i need to give a network path (\share\files)
But the \ is not working ..
strComputer = "."
strDirToMonitor = "c:\\\\test"
'// Monitor Above every 10 secs...
strTime = "10"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN " & strTime & " WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=" & Chr(34) & strDirToMonitor & Chr(34) & "'")
A network path is specified as follows:
\\COMPUTUER_NAME\SHARE\PATH. Obviously, you’d need to escape (double) the backslashes as you’d do with a local pathHowever, there are some differences in what you can do with network and local paths as remote ones aren’t controlled by your local machine – so I’m not sure if what you’re trying to accomplish will work.
Edit: As discussed in comments…