Results 1 to 9 of 9

Thread: Watching a folder

Threaded View

  1. #1

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Watching a folder

    I'm making a watch folder class, but at the moment I'm unable to figure out what would cause it to give the error #1, INVALID_FUNCTION. I'm trying to make an asynchronous call by giving the CompletionRoutine, but I just don't see what I'm doing against what is said over at MSDN.

    I know there are other VB6 codes that do work, but they always use events or synchronous processing, which means they're looping a tight loop with DoEvents to see if something has happened or not. This is not something I want. The callback code is tested and works with SelfTimer for an example (known as SelfCallback) - I did it like this to only have this one class and atleast some degree of IDE safety (but I'm pretty sure this is not enough).


    Some test code that I have put together, which just triggers the error from the Watch function:
    Code:
    Option Explicit
    
    Private WithEvents Folder As WatchFolder
    
    Private Sub Folder_Change(ByVal Filename As String, ByVal Action As WatchFileAction)
        Debug.Print Filename
    End Sub
    
    Private Sub Folder_Error(ByVal ErrorCode As Long)
        Debug.Print "Error #" & Hex$(ErrorCode)
    End Sub
    
    Private Sub Form_Load()
        Set Folder = New WatchFolder
        Folder.Watch "C:\Documents and Settings\"
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Set Folder = Nothing
    End Sub
    I had to attach the class.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width