Announcement

Collapse
No announcement yet.

FileSystemWatcher script (need help)

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

  • Malosa
    replied
    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,

    Leave a comment:


  • jon00
    replied
    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.

    Leave a comment:


  • Malosa
    replied
    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

    Leave a comment:


  • Uncle Michael
    replied
    Why not use Jon00's plug-in?
    http://board.homeseer.com/showthread.php?t=169604

    Leave a comment:


  • Malosa
    started a topic FileSystemWatcher script (need help)

    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 
Working...
X