• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

.NET Monitor Folder [SRC] Files and Folders

Status
Not open for further replies.

C.Oy

CoDDer
User
Joined
Feb 13, 2015
Messages
64
Reputation
0
Reaction score
479
Points
53
Credits
0
‎10 Years of Service‎
64%
Please note, if you want to make a deal with this user, that it is blocked.
Code:
Imports System.Threading
Imports System.IO
Public Class Form1
    Dim xCaminhoFolder As String = My.Computer.FileSystem.SpecialDirectories.Desktop
    Dim xNovaThread As Thread
    Dim xListaCoy As ListBox
    Dim xBlackList As String = Nothing
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        xVerificaArquivosInicio()
    End Sub
    Sub xVerificaArquivosInicio()
        Dim xArquivos() As String = Directory.GetFiles(xCaminhoFolder)
        Dim xPastas() As String = Directory.GetDirectories(xCaminhoFolder)
        For Each xFiles As String In xArquivos
            xBlackList += xFiles & vbNewLine
        Next
        For Each xPastinhas As String In xPastas
            xBlackList += xPastinhas & vbNewLine
        Next
        xNovaThread = New Thread(AddressOf xVerificaArquivos)
        xNovaThread.Start()
    End Sub
    Sub xVerificaArquivos()
        Do
            Dim xArquivos() As String = Directory.GetFiles(xCaminhoFolder)
            Dim xPastas() As String = Directory.GetDirectories(xCaminhoFolder)
            For Each xFiles As String In xArquivos
                If Not xBlackList.Contains(xFiles) Then
                    MsgBox("Arquivo: " & xFiles)
                    xBlackList += xFiles & vbNewLine
                End If
            Next
            For Each xPastinhas As String In xPastas
                If Not xBlackList.Contains(xPastinhas) Then
                    MsgBox("Pasta: " & xPastinhas)
                    xBlackList += xPastinhas & vbNewLine
                End If
            Next
            Thread.CurrentThread.Sleep(500)
        Loop
    End Sub
End Class
 ​

I did it for fun.
Checks if any files or folders were created on the desktop.
The folder path to be monitored can be changed.​
 
Status
Not open for further replies.
Back
Top