NSDFile メンバ(GetFileFolderCountで使用するメンバ)

ファイル、フォルダー数を非同期で取得します。


●コンストラクタ

名前 説明
NSDFile NSDFileを初期化します。

●プロパティの一覧

名前 説明
IsGetFileFolderCountRunning GetFileFolderCountが稼働中かを返します。
StopGetFileFolderCount ファイル、フォルダー数取得の中止を設定します。
SearchPatterndelimiter_FileFolderCount 検索パターンの区切り文字を設定します。

●メソッドの一覧

名前 引数 戻り値 説明
Dispose なし なし リソースの解放を行います。
GetFileFolderCount ( String , String , Boolean , FileAttributes , FileAttributes , FileAttributes, FileFolderCountEventHandler , FileFolderCountEventHandler , FileFolderCountEventHandler  ) Boolean型 ファイル、フォルダー数を取得します。

●イベントの一覧

名前 引数 戻り値 説明
Event_GetFileFolderCountOneAdd ( Object, NSDFileFolderCountEventArgs ) なし ファイル、フォルダー数取得の1ファイル取得時に返すイベント。
Event_GetFileFolderCountOneFolderEnd ( Object, NSDFileFolderCountEventArgs ) なし ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に返すイベント。
Event_GetFileFolderCountEnd ( Object, NSDFileFolderCountEventArgs ) なし ファイル、フォルダー数の取得終了時に返すイベント。

NSDFile(GetFileFolderCountで使用する)コンストラクタの説明

構文:Public Sub New()

使用法:Dim Cls_File As New NSDFile

引数:なし。

使用例:

Public Class Form1
    Dim Cls_File As New NSDFile
        :
End Class

NSDFile(GetFileFolderCountで使用する)プロパティの説明

名前:IsGetFileFolderCountRunning

構文:Public ReadOnly Property IsGetFileFolderCountRunning() As NSD_File_Run_Style

機能:GetFileFolderCountが稼働中かを返します。

Set値:なし。

Get値:稼働中かを返します。(NSD_File_Run_Style

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' 稼動有無で処理を分けます.
    Private Sub Button_GetFile_OK_Click( ByVal sender As System.Object, _
                                         ByVal e As System.EventArgs) _
                                         Handles Button_GetFile_OK.Click
        Try
            Select Case Cls_File.IsGetFileFolderCountRunning
                Case NSDFile.NSD_File_Run_Style.NotRunning
                    ' 稼動していません.
                Case NSDFile.NSD_File_Run_Style.Running
                    ' 稼働中です.
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class
名前:StopGetFileFolderCount
構文:Public Property StopGetFileFolderCount() As Boolean

機能:ファイル、フォルダー数取得の中止を設定します。

Set値:True :中止します。

False:中止しません。

Get値:Set値を参照。

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class
名前:SearchPatterndelimiter_FileFolderCount
構文:Public Property SearchPatterndelimiter_FileFolderCount() As String

機能:検索パターンの区切り文字を設定します。

Set値:検索パターンの区切り文字を設定。(初期地:"|")

Get値:Set値を参照。

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    Cls_File.SearchPatterndelimiter_FileFolderCount = "|"
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class

NSDFile(GetFileFolderCountで使用する)メソッドの説明

名前:Dispose
構文:Public Overridable Sub Dispose() Implements IDisposable.Dispose

機能:リソースの解放を行います。

※終了時に必ず呼び出します。

引数:なし。

戻り値:なし。

使用例:

Public Class Form1
    ' NSDFileを初期化.
    Dim Cls_File As New NSDFile

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub
End Class
名前:GetFileFolderCount
構文:Public Function GetFileFolderCount( Path , SearchPattern , SubFolder , Attributes , NotAttributes , NotCheckFolderAttributes , Event_GetFileFolderCountOneAdd , Event_GetFileFolderCountOneFolderEnd , Event_GetFileFolderCountEnd ) As Boolean

機能:ファイル、フォルダー数を取得します。

引数:

名前 引数渡しの方法 説明
Path String 値渡し(ByVal) ファイル、フォルダー数を取得するフォルダのフルパスを渡します。
SearchPattern String 値渡し(ByVal) 検索パターンを渡します。
※複数指定を行うときは、SearchPatterndelimiter_FileFolderCountで設定している文字で区切ります。
(デフォルトは"|")
例:"*.exe|*.dat"
SubFolder Boolean 値渡し(ByVal) サブフォルダーも取得するかを渡します。
True :サブフォルダーも取得します。
False:サブフォルダーは取得しません。
Attributes System.IO.FileAttributes 値渡し(ByVal) 取得するファイル属性を渡します。
0=全ての属性が対象になります。
NotAttributes System.IO.FileAttributes 値渡し(ByVal) 取得しないファイル属性を渡します。
0=取得しないファイル属性はありません。
NotCheckFolderAttributes System.IO.FileAttributes 値渡し(ByVal) 調査しないフォルダ属性を渡します。
0=全て調査します。
Event_GetFileFolderCountOneAdd FileFolderCountEventHandler 値渡し(ByVal) ファイル、フォルダー数取得の1ファイル取得時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。
Event_GetFileFolderCountOneFolderEn FileFolderCountEventHandler 値渡し(ByVal) ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。
Event_GetFileFolderCountEnd FileFolderCountEventHandler 値渡し(ByVal) ファイル、フォルダー数の取得終了時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。

戻り値:Boolean

戻り値の説明:

True:成功 False:失敗

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class

NSDFile(GetFileFolderCountで使用する)イベントの説明

 

名前:Event_GetFileFolderCountOneAdd

構文:Public Sub Event_GetFileFolderCountOneAdd( sender , e )

機能:ファイル、フォルダー数取得の1ファイル取得時に発生するイベント。

GetFileFolderCountの第7引数にアドレスを渡します。

引数:

名前 引数渡しの方法 説明
sender Object 値渡し(ByVal) Nothingが渡されます。
e NSDFileFolderCountEventArgs 値渡し(ByVal) ファイル、フォルダー数取得用のイベントが渡されます。

戻り値:なし。

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class

 

名前:Event_GetFileFolderCountOneFolderEnd

構文:Public Sub Event_GetFileFolderCountOneFolderEnd( sender , e )

機能:ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント。

GetFileFolderCountの第8引数にアドレスを渡します。

引数:

名前 引数渡しの方法 説明
sender Object 値渡し(ByVal) Nothingが渡されます。
e NSDFileFolderCountEventArgs 値渡し(ByVal) ファイル、フォルダー数取得用のイベントが渡されます。

戻り値:なし。

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class
名前:Event_GetFileFolderCountEnd

構文:Public Sub Event_GetFileFolderCountEnd( sender , e )

機能:ファイル、フォルダー数の取得終了時に発生するイベント。

GetFileFolderCountの第9引数にアドレスを渡します。

引数:

名前 引数渡しの方法 説明
sender Object 値渡し(ByVal) Nothingが渡されます。
e NSDFileFolderCountEventArgs 値渡し(ByVal) ファイル、フォルダー数取得用のイベントが渡されます。

戻り値:なし。

使用例:

Public Class Form1
    ' NSDFileを初期化します.
    Dim Cls_File As New NSDFile
    ' ファイル、フォルダー数の取得フラグ True:取得中 False:取得していません.
    Dim BlnCls_GetFileFolder As Boolean = False

    ' FormClosing.
    Private Sub Form1_FormClosing(ByVal sender As Object, _
                                  ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                  ) Handles Me.FormClosing
        Try
            ' NSDFileの解放.
            If Not (Cls_File Is Nothing) Then
                Cls_File.Dispose()
                Cls_File = Nothing
            End If
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数を取得します.
    Private Sub Button_GetFile_Click( ByVal sender As System.Object, _
                                      ByVal e As System.EventArgs _
                                      ) Handles Button_GetFile.Click
        Try
            Select Case BlnCls_GetFileFolder
                Case False
                    BlnCls_GetFileFolder = Cls_File.GetFileFolderCount(Me.TextBox1.Text, _
                                                                       Me.TextBox_SearchPattern.Text, _
                                                                       True, _
                                                                       0, _
                                                                       0, _
                                                                       IO.FileAttributes.System , _
                                                                       AddressOf GetFileFolderCountOneAdd_Callback, _
                                                                       AddressOf GetFileFolderCountOneFolderEnd_Callback, _
                                                                       AddressOf GetFileFolderCountEnd_Callback)
                    If BlnCls_GetFileFolder Then
                        Me.Button_GetFile.Text = "中止"
                    Else
                        MsgBox("ファイル、フォルダー数が取れません。")
                    End If

                Case True
                    ' 取得を中止します.
                    Me.Button_GetFile.Text = "ファイル、フォルダー数の取得"
                    ' 取得の中止.
                    Cls_File.StopGetFileFolderCount = True
                    BlnCls_GetFileFolder = False
            End Select
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1ファイル取得時に発生するイベント関数.
    Private Sub GetFileFolderCountOneAdd_Callback(ByVal sender As Object, _
                                                  ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
            If (・・・・) Then
                e.SearchStop = True
            End If
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイル、フォルダー数取得の1フォルダー内のファイル取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountOneFolderEnd_Callback(ByVal sender As Object, _
                                                        ByVal e As NSDFileFolderCountEventArgs)
        Try
            :
        Catch ex As Exception
        End Try
    End Sub

    ' ファイルまたはフォルダー数取得終了時に発生するイベント関数.
    Private Sub GetFileFolderCountEnd_Callback(ByVal sender As Object, _
                                               ByVal e As NSDFileFolderCountEventArgs)
        Try
            ' ファイル数.
            MsgBox("ファイル数:" & e.FileCount & " フォルダー数:" & e.FolderCount)
            BlnCls_GetFileFolder = False    
        Catch ex As Exception
        End Try
    End Sub
End Class

Copyright (C) 2010-2012 Nihon System Developer Corp. All Rights Reserved.