Hi,
I'm creating a module which waits for XML files to appear in a directory. The problem I have is......it just wont work. Here is the code, can anyone help?
Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity
Imports Microsoft.VisualBasic.ControlChars
Imports System.Xml
Imports System.IO
Imports System.Diagnostics
Namespace DotNetNuke.Modules.XMLFileSearch
Public Class XMLFileSearch
Inherits Entities.Modules.PortalModuleBase
Protected Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
If IsInRole("Registered Users") Or _
IsInRole("Administrators") Then
Run()
Else
'Add code here
End If
End Sub
Private Shared Sub Run()
' Create a new FileSystemWatcher and set its properties.
Dim watcher As New FileSystemWatcher()
watcher.Path = "C:\XML"
' Watch for changes in LastAccess and LastWrite times, and
' the renaming of files or directories. Add all notify filters until it works then remove
watcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName Or NotifyFilters.CreationTime)
' Only watch xml files.
watcher.Filter = "*.xml"
' Add event handlers.
‘Use watcher.changed to see if code works. Remove when working.
AddHandler watcher.Changed, AddressOf OnChanged
AddHandler watcher.Created, AddressOf OnChanged
' Begin watching.
watcher.EnableRaisingEvents = True
End Sub
Public Shared Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)
' Specify what is done when a file is changed, created, or deleted.
Dim label2 As New Label
label2.BackColor = Color.Green
label2.Text = "File received....."
‘Process the file. Code below
‘Change label3 text to processed
Dim label3 As New Label
Label3.BackColor = Color.Green
Label3.Text = "File Processed"
End Sub
End Class
End Namespace