Announcement

Collapse
No announcement yet.

FileSystemWatcher script (need help)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FileSystemWatcher script (need help)

    Hi all

    i have a FileSystemWatcher script that i want to port to homeseer

    i try some things but i get alway an error identifier expected..


    this is the script.

    hope someone can help me


    PHP Code:
    Imports System.IO
    Imports System
    .Diagnostics

    dim watchfolder 
    As FileSystemWatcher
        Sub Main
    (ByVal Parms As Object)
        
    watchfolder = New System.IO.FileSystemWatcher()
        
    watchfolder.Path "C:\test\"
        watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
        watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _
                                   IO.NotifyFilters.FileName
        watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _
                                   IO.NotifyFilters.Attributes
        AddHandler watchfolder.Changed, AddressOf logchange
        AddHandler watchfolder.Created, AddressOf logchange
        AddHandler watchfolder.Deleted, AddressOf logchange
        AddHandler watchfolder.Renamed, AddressOf logrename
        watchfolder.EnableRaisingEvents = True
    End Sub


     Private Sub logchange(ByVal source As Object, ByVal e As  _
                            System.IO.FileSystemEventArgs)
            If e.ChangeType = IO.WatcherChangeTypes.Changed Then
                hs.writelog("
    File " & e.FullPath & _
                                         " 
    has been modified" & vbCrLf)
            End If
            If e.ChangeType = IO.WatcherChangeTypes.Created Then
                hs.writelog("
    File" & e.FullPath & _" has been created" & vbCrLf)
            End If
            If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
                hs.writelog("
    File " & e.FullPath & _
                                         " 
    has been deleted" & vbCrLf)
            End If
        End Sub
        Public Sub logrename(ByVal source As Object, ByVal e As  _
                                System.IO.RenamedEventArgs)
            hs.writelog("
    File" & e.OldName & _
                             " 
    has been renamed to " & e.Name & vbCrLf)
    End Sub 
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

  • #2
    Why not use Jon00's plug-in?
    http://board.homeseer.com/showthread.php?t=169604
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

    Comment


    • #3
      Thanks

      i didn't know Jon had one .


      but i wanted to implement it into my script , thats why i wanted to port that script

      thanks for the reply

      Originally posted by Uncle Michael View Post
      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




      HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

      Comment


      • #4
        You cannot really use FileWatcher to monitor a file in a script. If you did, the script would have to run continuously and never terminate.

        It would be very bad practice to do so in Homeseer.
        Jon

        Comment


        • #5
          hi jon


          no not in this script what im building.
          it uses a second one to use as a recurring ,
          otherwise indeed homeseer would use a lot of cpu .

          but ill write in my doc that they can download your script to use it also so no problem



          regards,
          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




          HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

          Comment

          Working...
          X