none
Detectar si un archivo se esta enviando por correo. RRS feed

  • Pregunta

  • Buenas, tengo una duda. Quisiera saber si existe una manera de detectar si un archivo esta siendo subido a una pagina o en este caso, si se esta subiendo, para enviar por correo.

    Eh intentado con FileSystemWatcher, pero no he tenido exito :/

        Private Sub Wachter()
            Dim MyWatcher As New System.IO.FileSystemWatcher() ' crea un nuevo objeto System.IO.FileSystemWatcher()
            MyWatcher.Path = txtPath.Text ' 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)
            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
            MessageBox.Show("Changed: " & WChanged & "\nCreated: " & WCreated & "\nRenamed: " & WRenamed & "\nDeleted: " & WDeleted)
        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


    jueves, 5 de marzo de 2020 15:59