追加的条目编号,以FileSystemWatcher的输出

问题描述 投票:1回答:1

好的,

大概将在这里看作是一个极其电枢后,我真的不精通VB或太大的程序员,但我是一个“边做边学”的驱动器上。

我正在开发这为用户创建目录的应用程序,并跟踪创建的目录和更改使用FileSystemWatcher的这些目录。

我有了这个小片段至今(更新在回答您您的意见吉米):

Button_Click的私人小组:

    watchfolder = New System.IO.FileSystemWatcher()
    watchfolder.Path = TodaysScanFolder
    watchfolder.Filter = ""
    watchfolder.IncludeSubdirectories = True

    watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
    watchfolder.NotifyFilter = watchfolder.NotifyFilter Or
                       IO.NotifyFilters.FileName
    watchfolder.NotifyFilter = watchfolder.NotifyFilter Or
                       IO.NotifyFilters.Attributes

    AddHandler watchfolder.Created, AddressOf logchange
    AddHandler watchfolder.Deleted, AddressOf logchange

    watchfolder.EnableRaisingEvents = True
    btnStartScan.Enabled = False
    btnStopScan.Enabled = True
End Sub

    Public Sub logchange(ByVal source As Object, ByVal e As _
                        System.IO.FileSystemEventArgs)

    If e.ChangeType = IO.WatcherChangeTypes.Created Then
        txt_folderactivity.Text &= "File " & e.FullPath &
                                 " has been created" & vbCrLf
    End If
    If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
        txt_folderactivity.Text &= "File " & e.FullPath &
                                " has been deleted" & vbCrLf
    End If
End Sub

对于每个附加的活性,我想追加输出到txt_folderactivity.Text用1,在此之前。然后2,3,等等等等。

你看这个文本框,在改变输出写入像这样的文本文件:

Private Sub txt_folderactivity_TextChanged(sender As Object, e As EventArgs) Handles txt_folderactivity.TextChanged
    str = txt_folderactivity.Text
    My.Computer.FileSystem.WriteAllText(LogFileLoc, str, True)
End Sub

我想每一行/进入到文本文件,开始1,2,3等等。另外,正如我所说的用VB总初学者,似乎已经拼凑起来的东西,看起来有点乱,但功能齐全,将关键业务,对相关的VB学习资源一个良好的开端任何指针将是非常有益的。感谢所有

vb.net math filesystemwatcher
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.