Ver Mensaje Individual
  #7 (permalink)  
Antiguo 21/05/2004, 02:30
Avatar de kachalot
kachalot
 
Fecha de Ingreso: mayo-2004
Ubicación: Castellon
Mensajes: 173
Antigüedad: 20 años, 9 meses
Puntos: 0
CODIGO

ESTO ES LO Q TENGO EN EL MODULE...


Public Cambiar, Borrar, Crear, Renombrar As String
Public DirActual As String




Public Sub Wachter()
Dim MyWatcher As New System.IO.FileSystemWatcher ' crea un nuevo objeto System.IO.FileSystemWatcher()
MyWatcher.Path = DirActual ' directorio a monitorear
MyWatcher.IncludeSubdirectories = True ' indica si se deben monitorear los subdirectorios
'======EVENTOS
AddHandler MyWatcher.Changed, AddressOf OnChanged
AddHandler MyWatcher.Created, AddressOf OnCreated
AddHandler MyWatcher.Deleted, AddressOf OnDeleted
AddHandler MyWatcher.Renamed, AddressOf OnRenamed
MyWatcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName)
MyWatcher.EnableRaisingEvents = True
End Sub

Public WChanged As Integer '1
Public WCreated As Integer '2
Public WRenamed As Integer '3
Public WDeleted As Integer '4

Public Sub SetStatics(ByVal val As Integer)

Dim fIni As New inicial

Select Case val
Case 1
WChanged = WChanged + 1
Case 2
WCreated = WCreated + 1
Case 3
WRenamed = WRenamed + 1
Case 4
WDeleted = WDeleted + 1
End Select
Cambiar = WChanged
Borrar = WDeleted
Crear = WCreated
Renombrar = WRenamed


'fIni.lCam.Text = Cambiar
'fIni.lBor.Text = Borrar
'fIni.lCre.Text = Crear
'fIni.lRen.Text = Renombrar

fIni.ControlarEventos()

End Sub

Public Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs) ' se dispara cuando se modifica o accede a un archivo
SetStatics(1)
End Sub

Public Sub OnDeleted(ByVal source As Object, ByVal e As FileSystemEventArgs) ' al eliminar un archivo
SetStatics(4)
End Sub

Public Sub OnCreated(ByVal source As Object, ByVal e As FileSystemEventArgs) ' al crear un archivo
SetStatics(2)
End Sub

Public Sub OnRenamed(ByVal source As Object, ByVal e As RenamedEventArgs) ' renombrar un archivo
SetStatics(3)
End Sub

==============================================
==============================================

ESTO OTRO ES EL FORM Q QUIERE HACER USO DE LAS VARIABLES...

Private Sub bMon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bMon.Click

'Dim pmaWat As New pmaWatcher

Module1.DirActual = lDirAct.Text

pmaWat.Wachter()

lCam.Text = Cambiar
lBor.Text = Borrar
lCre.Text = Crear
lRen.Text = Renombrar

End Sub

Public Sub ControlarEventos()

Dim x As String
'Dim pmaWat As New pmaWatcher

x = Crear

lCam.Text = Cambiar
lBor.Text = Borrar
lCre.Text = Crear
lRen.Text = Renombrar

End Sub


Lo curioso es q viendolo paso a paso,
lCam.Text = Cambiar
lBor.Text = Borrar
lCre.Text = Crear
lRen.Text = Renombrar
todo tiene valor pero a la hora de sacarlo por pantalla, na de na........?????

Gracias