NSDFile メンバ(GetFolderListで使用するメンバ)
フォルダーリストを非同期で取得します。
●コンストラクタ
名前 説明 NSDFile NSDFileを初期化します。
●プロパティの一覧
名前 説明 IsGetFolderRunning GetFolderListが稼働中かを返します。 StopGetFolderList フォルダーリストの中止を設定します。
●メソッドの一覧
名前 引数 戻り値 説明 Dispose なし なし リソースの解放を行います。 GetFolderList ( String , Boolean , FileListEventHandler , FileListEventHandler ) Boolean型 パス、サブフォルダーの取得有無を指定してフォルダーリストを取得します。 ( String , Boolean , FileAttributes , FileAttributes , FileListEventHandler , FileListEventHandler ) Boolean型 パス、サブフォルダーの取得有無、取得属性を指定してフォルダーリストを取得します。 ( String , Boolean , FileAttributes , FileAttributes , Boolean , FileListEventHandler , FileListEventHandler ) Boolean型 パス、サブフォルダーの取得有無、取得属性、アクセス可能のみの有無を指定してフォルダーリストを取得します。 Dispose_GetFolderList_Collections なし。 Boolean型 GetFolderList用のCollectionsを解放します。
●イベントの一覧
名前 引数 戻り値 説明 Event_GetFolderListOneAdd ( Object, NSDFileFolderListEventArgs ) なし フォルダーリストに1フォルダー追加された時に返すイベント。 Event_GetFolderListEnd ( Object, NSDFileFolderListEventArgs ) なし フォルダーリストの取得終了時に返すイベント。
●NSDFile(GetFolderListで使用する)コンストラクタの説明
構文:Public Sub New()
使用法:Dim Cls_File As New NSDFile
引数:なし。
使用例:
Public Class Form1 Dim Cls_File As New NSDFile : End Class
●NSDFile(GetFolderListで使用する)プロパティの説明
名前:IsGetFolderRunning
構文:Public ReadOnly Property IsGetFolderRunning() As NSD_File_Run_Style
機能:GetFolderListが稼働中かを返します。
Set値:なし。
Get値:稼働中かを返します。(NSD_File_Run_Style)
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ 0, _ 0, _ True, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = 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.IsGetFolderRunning 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 GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub End Class
名前:StopGetFolderList
構文:Public Property StopGetFolderList() As Boolean 機能:フォルダーリストの中止を設定します。
Set値:True :中止します。
False:中止しません。
Get値:Set値を参照。
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ 0, _ 0, _ True, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = 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.IsGetFolderRunning 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 GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try With e.List ' フォルダー取得. Dim FI As System.IO.DirectoryInfo = .Item(.Count - 1) Dim Str_FullName As String = FI.FullName ' リストボックスに追加します. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf AddFileList), New Object() {Str_FullName} ) Else Me.AddFileList(Str_FullName) End If End With Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try ' ボタンのテキストを設定. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf SetButton_FileList), New Object() {"リストの取得"} ) Else Me.SetButton_FileList("リストの取得") End If MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub ' フォルダー取得用リストボックスに追加します. Public Sub AddFileList(ByVal StrVal_FileName As String) Try Me.ListBox1.Items.Add(StrVal_FileName) Me.Label_ListCount.Text = "取得件数:" & Me.ListBox1.Items.Count Catch ex As Exception End Try End Sub ' リスト取得用ボタンのテキスト設定. Public Sub SetButton_FileList(ByVal StrVal_Text As String) Try Me.Button_GetFile.Text = StrVal_Text Catch ex As Exception End Try End Sub End Class
●NSDFile(GetFolderListで使用する)メソッドの説明
名前: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
名前:GetFolderList
機能:フォルダーリストを取得します。
@パス、サブフォルダーの取得有無を指定してフォルダーリストを取得します。 構文:Public Function GetFolderList( Path , SubFolder , Event_GetFolderListOneAdd , Event_GetFolderListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) フォルダーリストを取得するフォルダのフルパス名を渡します。 SubFolder Boolean 値渡し(ByVal) サブフォルダーの取得有無を渡します。
True :サブフォルダーも取得します。
False:サブフォルダーは取得しません。Event_GetFolderListOneAdd FileListEventHandler 値渡し(ByVal) フォルダーリストに1フォルダー追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFolderListEnd FileListEventHandler 値渡し(ByVal) フォルダーリストの取得終了時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。戻り値:Boolean
戻り値の説明:
True:成功 False:失敗
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = True BlnCls_GetFileFolder = False End Select Catch ex As Exception End Try End Sub ' フォルダーを1件取得した時に呼び出されるイベント関数. Private Sub GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try With e.List ' フォルダー取得. Dim FI As System.IO.DirectoryInfo = .Item(.Count - 1) Dim Str_FullName As String = FI.FullName ' リストボックスに追加します. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf AddFileList), New Object() {Str_FullName} ) Else Me.AddFileList(Str_FullName) End If End With Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try ' ボタンのテキストを設定. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf SetButton_FileList), New Object() {"リストの取得"} ) Else Me.SetButton_FileList("リストの取得") End If MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub ' フォルダー取得用リストボックスに追加します. Public Sub AddFileList(ByVal StrVal_FileName As String) Try Me.ListBox1.Items.Add(StrVal_FileName) Me.Label_ListCount.Text = "取得件数:" & Me.ListBox1.Items.Count Catch ex As Exception End Try End Sub ' リスト取得用ボタンのテキスト設定. Public Sub SetButton_FileList(ByVal StrVal_Text As String) Try Me.Button_GetFile.Text = StrVal_Text Catch ex As Exception End Try End Sub End Class
Aパス、サブフォルダーの取得有無、取得属性を指定してフォルダーリストを取得します。 構文:Public Function GetFolderList( Path , SubFolder , Attributes , NotAttributes , Event_GetFolderListOneAdd , Event_GetFolderListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) フォルダーリストを取得するフォルダのフルパス名を渡します。 SubFolder Boolean 値渡し(ByVal) サブフォルダーの取得有無を渡します。
True :サブフォルダーも取得します。
False:サブフォルダーは取得しません。Attributes System.IO.FileAttributes 値渡し(ByVal) 取得するフォルダー属性を渡します。
0=全ての属性が対象になります。NotAttributes System.IO.FileAttributes 値渡し(ByVal) 取得しないフォルダー属性を渡します。
0=取得しないフォルダー属性はありません。Event_GetFolderListOneAdd FileListEventHandler 値渡し(ByVal) フォルダーリストに1フォルダー追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFolderListEnd FileListEventHandler 値渡し(ByVal) フォルダーリストの取得終了時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。戻り値:Boolean
戻り値の説明:
True:成功 False:失敗
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ 0, _ 0, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = True BlnCls_GetFileFolder = False End Select Catch ex As Exception End Try End Sub ' フォルダーを1件取得した時に呼び出されるイベント関数. Private Sub GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try With e.List ' フォルダー取得. Dim FI As System.IO.DirectoryInfo = .Item(.Count - 1) Dim Str_FullName As String = FI.FullName ' リストボックスに追加します. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf AddFileList), New Object() {Str_FullName} ) Else Me.AddFileList(Str_FullName) End If End With Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try ' ボタンのテキストを設定. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf SetButton_FileList), New Object() {"リストの取得"} ) Else Me.SetButton_FileList("リストの取得") End If MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub ' フォルダー取得用リストボックスに追加します. Public Sub AddFileList(ByVal StrVal_FileName As String) Try Me.ListBox1.Items.Add(StrVal_FileName) Me.Label_ListCount.Text = "取得件数:" & Me.ListBox1.Items.Count Catch ex As Exception End Try End Sub ' リスト取得用ボタンのテキスト設定. Public Sub SetButton_FileList(ByVal StrVal_Text As String) Try Me.Button_GetFile.Text = StrVal_Text Catch ex As Exception End Try End Sub End Class
Bパス、サブフォルダーの取得有無、取得属性、アクセス可能のみの有無を指定してフォルダーリストを取得します。 構文:Public Function GetFolderList( Path , SubFolder , Attributes , NotAttributes , AccessFolder , Event_GetFolderListOneAdd , Event_GetFolderListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) フォルダーリストを取得するフォルダのフルパス名を渡します。 SubFolder Boolean 値渡し(ByVal) サブフォルダーの取得有無を渡します。
True :サブフォルダーも取得します。
False:サブフォルダーは取得しません。Attributes System.IO.FileAttributes 値渡し(ByVal) 取得するフォルダー属性を渡します。
0=全ての属性が対象になります。NotAttributes System.IO.FileAttributes 値渡し(ByVal) 取得しないフォルダー属性を渡します。
0=取得しないフォルダー属性はありません。AccessFolder Boolean 値渡し(ByVal) アクセスができるフォルダのみ取得かを渡します。
True :アクセスができるフォルダのみ取得します。
False:アクセスができないフォルダも取得します。Event_GetFolderListOneAdd FileListEventHandler 値渡し(ByVal) フォルダーリストに1フォルダー追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFolderListEnd FileListEventHandler 値渡し(ByVal) フォルダーリストの取得終了時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。戻り値:Boolean
戻り値の説明:
True:成功 False:失敗
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ 0, _ 0, _ True, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = True BlnCls_GetFileFolder = False End Select Catch ex As Exception End Try End Sub ' フォルダーを1件取得した時に呼び出されるイベント関数. Private Sub GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try With e.List ' フォルダー取得. Dim FI As System.IO.DirectoryInfo = .Item(.Count - 1) Dim Str_FullName As String = FI.FullName ' リストボックスに追加します. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf AddFileList), New Object() {Str_FullName} ) Else Me.AddFileList(Str_FullName) End If End With Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try ' ボタンのテキストを設定. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf SetButton_FileList), New Object() {"リストの取得"} ) Else Me.SetButton_FileList("リストの取得") End If MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub ' フォルダー取得用リストボックスに追加します. Public Sub AddFileList(ByVal StrVal_FileName As String) Try Me.ListBox1.Items.Add(StrVal_FileName) Me.Label_ListCount.Text = "取得件数:" & Me.ListBox1.Items.Count Catch ex As Exception End Try End Sub ' リスト取得用ボタンのテキスト設定. Public Sub SetButton_FileList(ByVal StrVal_Text As String) Try Me.Button_GetFile.Text = StrVal_Text Catch ex As Exception End Try End Sub End Class
名前:Dispose_GetFolderList_Collections
構文:Public Function Dispose_GetFolderList_Collections() As Boolean
機能:GetFolderList用のCollectionsを解放します。
引数:なし。
戻り値:Boolean
戻り値の説明:
True:成功 False:失敗
使用例:
NSDFile内で使用されるので使用例はありません。
●NSDFile(GetFolderListで使用する)イベントの説明
名前:Event_GetFolderListOneAdd
構文:Public Sub Event_GetFolderListOneAdd( sender , e )
機能:フォルダーリストに1フォルダー追加された時に発生するイベント。
※GetFolderListの引数にアドレスを渡します。
引数:
名前 型 引数渡しの方法 説明 sender Object 値渡し(ByVal) Nothingが渡されます。 e NSDFileFolderListEventArgs 値渡し(ByVal) ファイル、フォルダーリスト用のイベントが渡されます。 戻り値:なし。
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ 0, _ 0, _ True, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = True BlnCls_GetFileFolder = False End Select Catch ex As Exception End Try End Sub ' フォルダーを1件取得した時に呼び出されるイベント関数. Private Sub GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try With e.List ' フォルダー取得. Dim FI As System.IO.DirectoryInfo = .Item(.Count - 1) Dim Str_FullName As String = FI.FullName ' リストボックスに追加します. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf AddFileList), New Object() {Str_FullName} ) Else Me.AddFileList(Str_FullName) End If End With Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try ' ボタンのテキストを設定. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf SetButton_FileList), New Object() {"リストの取得"} ) Else Me.SetButton_FileList("リストの取得") End If MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub ' フォルダー取得用リストボックスに追加します. Public Sub AddFileList(ByVal StrVal_FileName As String) Try Me.ListBox1.Items.Add(StrVal_FileName) Me.Label_ListCount.Text = "取得件数:" & Me.ListBox1.Items.Count Catch ex As Exception End Try End Sub ' リスト取得用ボタンのテキスト設定. Public Sub SetButton_FileList(ByVal StrVal_Text As String) Try Me.Button_GetFile.Text = StrVal_Text Catch ex As Exception End Try End Sub End Class
名前:Event_GetFolderListEnd
構文:Public Sub Event_GetFolderListEnd( sender , e )
機能:フォルダーリストの取得終了時に発生するイベント。
※GetFolderListの引数にアドレスを渡します。
引数:
名前 型 引数渡しの方法 説明 sender Object 値渡し(ByVal) Nothingが渡されます。 e NSDFileFolderListEventArgs 値渡し(ByVal) ファイル、フォルダーリスト用のイベントが渡されます。 戻り値:なし。
使用例:
Public Class Form1 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 ' リストを取得します. 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' フォルダーリスト取得. BlnCls_GetFileFolder = Cls_File.GetFolderList(Me.TextBox1.Text, _ True , _ 0, _ 0, _ True, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFolderList = True BlnCls_GetFileFolder = False End Select Catch ex As Exception End Try End Sub ' フォルダーを1件取得した時に呼び出されるイベント関数. Private Sub GetFileListOneAdd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try With e.List ' フォルダー取得. Dim FI As System.IO.DirectoryInfo = .Item(.Count - 1) Dim Str_FullName As String = FI.FullName ' リストボックスに追加します. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf AddFileList), New Object() {Str_FullName} ) Else Me.AddFileList(Str_FullName) End If End With Catch ex As Exception End Try End Sub ' フォルダーリスト取得終了時に呼び出されるイベント関数. Private Sub GetFileListEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try ' ボタンのテキストを設定. If Me.InvokeRequired Then Me.Invoke(New SetName_Invoke(AddressOf SetButton_FileList), New Object() {"リストの取得"} ) Else Me.SetButton_FileList("リストの取得") End If MsgBox("検索が終了しました。") BlnCls_GetFileFolder = False Catch ex As Exception End Try End Sub ' フォルダー取得用リストボックスに追加します. Public Sub AddFileList(ByVal StrVal_FileName As String) Try Me.ListBox1.Items.Add(StrVal_FileName) Me.Label_ListCount.Text = "取得件数:" & Me.ListBox1.Items.Count Catch ex As Exception End Try End Sub ' リスト取得用ボタンのテキスト設定. Public Sub SetButton_FileList(ByVal StrVal_Text As String) Try Me.Button_GetFile.Text = StrVal_Text Catch ex As Exception End Try End Sub End Class
Copyright (C) 2010-2012 Nihon System Developer Corp. All Rights Reserved.