-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectoryChanges.vb
More file actions
76 lines (62 loc) · 2.31 KB
/
Copy pathDirectoryChanges.vb
File metadata and controls
76 lines (62 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Imports System.IO
Public Class FileSystemWatcher
Private WithEvents dc As IO.FileSystemWatcher
Public Structure ItemChanges
Public Enum CanBeChanges As Byte
Changed = 0
Created = 1
Delete = 2
Renamed = 3
End Enum
Dim Changes As CanBeChanges
Dim Name As String
Dim FullPath As String
Dim ChangeType As WatcherChangeTypes
Dim Param As Object
End Structure
Protected Changes() As ItemChanges
Private Sub Add(ByVal Changes As ItemChanges.CanBeChanges, ByVal Name As String, ByVal FullName As String, ByVal ChangeType As WatcherChangeTypes, Optional ByVal Param As Object = Nothing)
Dim Ilgis As Integer
If IsNothing(Me.Changes) Then
Ilgis = 0
Else
Ilgis = Me.Changes.Length
End If
ReDim Preserve Me.Changes(Ilgis + 1)
With Me.Changes(Ilgis)
.Changes = Changes
.FullPath = FullName
.Name = Name
.ChangeType = ChangeType
.Param = Param
End With
End Sub
Private Sub dc_Changed(ByVal sender As Object, ByVal e As FileSystemEventArgs) Handles dc.Changed
Me.Add(ItemChanges.CanBeChanges.Changed, e.Name, e.FullPath, e.ChangeType)
End Sub
Private Sub dc_Created(ByVal sender As Object, ByVal e As FileSystemEventArgs) Handles dc.Created
Me.Add(ItemChanges.CanBeChanges.Created, e.Name, e.FullPath, e.ChangeType)
End Sub
Private Sub dc_Deleted(ByVal sender As Object, ByVal e As FileSystemEventArgs) Handles dc.Deleted
Me.Add(ItemChanges.CanBeChanges.Delete, e.Name, e.FullPath, e.ChangeType)
End Sub
Private Sub dc_Renamed(ByVal sender As Object, ByVal e As RenamedEventArgs) Handles dc.Renamed
Dim Mas() As Object = {e.OldName, e.OldFullPath}
Me.Add(ItemChanges.CanBeChanges.Renamed, e.Name, e.FullPath, e.ChangeType)
End Sub
Public Sub Clear()
ReDim Me.Changes(0)
End Sub
Public ReadOnly Property Length()
Get
If IsNothing(Me.Changes) Then Return 0
Return Me.Changes.Length
End Get
End Property
Sub New(ByVal Path As String)
Try
Me.dc = New IO.FileSystemWatcher(Path)
Catch ex As Exception
End Try
End Sub
End Class