NSDFile メンバ(GetFileListで使用するメンバ)
ファイルリストを非同期で取得します。
●コンストラクタ
名前 説明 NSDFile NSDFileを初期化します。
●プロパティの一覧
名前 説明 IsGetFileRunning GetFileListが稼働中かを返します。 StopGetFileList ファイルリストの中止を設定します。 SearchPatterndelimiter 検索パターンの区切り文字を設定します。
●メソッドの一覧
●イベントの一覧
名前 引数 戻り値 説明 Event_GetFileListOneAdd ( Object, NSDFileFolderListEventArgs ) なし ファイルを1件取得した時に返すイベント。 Event_GetFileListOneFolderEnd ( Object, NSDFileFolderListEventArgs ) なし 1フォルダーのファイル取得後に返すイベント。 Event_GetFileListOneAllFolderEnd ( Object, NSDFileFolderListEventArgs ) なし 1フォルダーのフォルダー取得後に返すイベント。 Event_GetFileListEnd ( Object, NSDFileFolderListEventArgs ) なし ファイルリスト取得終了時に返すイベント。
●NSDFile(GetFileListで使用する)コンストラクタの説明
構文:Public Sub New()
使用法:Dim Cls_File As New NSDFile
引数:なし。
使用例:
Public Class Form1 Dim Cls_File As New NSDFile : End Class
●NSDFile(GetFileListで使用する)プロパティの説明
名前:IsGetFileRunning
構文:Public ReadOnly Property IsGetFileRunning() As NSD_File_Run_Style
機能:GetFileListが稼働中かを返します。
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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.IsGetFileRunning 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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
名前:StopGetFileList
構文:Public Property StopGetFileList() 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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
名前:SearchPatterndelimiter
構文:Public Property SearchPatterndelimiter() 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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' 検索パターンの区切り文字を設定します. Cls_File.SearchPatterndelimiter = "|" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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(GetFileListで使用する)メソッドの説明
名前: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
名前:GetFileList
機能:ファイルリストを取得します。
@パス、サブフォルダーの取得有無を指定してファイルリストを取得します。 構文:Public Function GetFileList( Path , SubFolder , Event_GetFileListOneAdd , Event_GetFileListOneFolderEnd , Event_GetFileListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) ファイルリストを取得するフォルダのフルパスを渡します。 SubFolder Boolean 値渡し(ByVal) サブフォルダーも取得するかを渡します。
True :サブフォルダーも取得します。
False:サブフォルダーは取得しません。Event_GetFileListOneAdd FileListEventHandler 値渡し(ByVal) ファイルリストに1ファイル追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListOneFolderEnd FileListEventHandler 値渡し(ByVal) 1フォルダーのファイル取得後に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListEnd FileListEventHandler 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ True , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_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 ' ボタンのテキストを設定. 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 GetFileList( Path , SearchPattern , SubFolder , Event_GetFileListOneAdd , Event_GetFileListOneFolderEnd , Event_GetFileListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) ファイルリストを取得するフォルダのフルパスを渡します。 SearchPattern String 値渡し(ByVal) 検索パターンを渡します。
※複数指定を行うときは、SearchPatterndelimiterで設定している文字で区切ります。
(デフォルトは"|")
例:"*.exe|*.dat"SubFolder Boolean 値渡し(ByVal) サブフォルダーも取得するかを渡します。
True :サブフォルダーも取得します。
False:サブフォルダーは取得しません。Event_GetFileListOneAdd FileListEventHandler 値渡し(ByVal) ファイルリストに1ファイル追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListOneFolderEnd FileListEventHandler 値渡し(ByVal) 1フォルダーのファイル取得後に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListEnd FileListEventHandler 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_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 ' ボタンのテキストを設定. 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 GetFileList( Path , SearchPattern , SubFolder , Attributes , NotAttributes , Event_GetFileListOneAdd , Event_GetFileListOneFolderEnd , Event_GetFileListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) ファイルリストを取得するフォルダのフルパスを渡します。 SearchPattern String 値渡し(ByVal) 検索パターンを渡します。
※複数指定を行うときは、SearchPatterndelimiterで設定している文字で区切ります。
(デフォルトは"|")
例:"*.exe|*.dat"SubFolder Boolean 値渡し(ByVal) サブフォルダーも取得するかを渡します。
True:サブフォルダーも取得します。
False:サブフォルダーは取得しません。Attributes System.IO.FileAttributes 値渡し(ByVal) 取得するファイル属性を渡します。
0=全ての属性が対象になります。NotAttributes System.IO.FileAttributes 値渡し(ByVal) 取得しないファイル属性を渡します。
0=取得しないファイル属性はありません。Event_GetFileListOneAdd FileListEventHandler 値渡し(ByVal) ファイルリストに1ファイル追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListOneFolderEnd FileListEventHandler 値渡し(ByVal) 1フォルダーのファイル取得後に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListEnd FileListEventHandler 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_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 ' ボタンのテキストを設定. 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
Cパス、検索パターン、サブフォルダーの取得有無、取得属性、調査しないフォルダー属性を指定してファイルリストを取得します。 構文:Public Function GetFileList( Path , SearchPattern , SubFolder , Attributes , NotAttributes , NotCheckFolderAttributes , Event_GetFileListOneAdd , Event_GetFileListOneFolderEnd , Event_GetFileListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) ファイルリストを取得するフォルダのフルパスを渡します。 SearchPattern String 値渡し(ByVal) 検索パターンを渡します。
※複数指定を行うときは、SearchPatterndelimiterで設定している文字で区切ります。
(デフォルトは"|")
例:"*.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_GetFileListOneAdd FileListEventHandler 値渡し(ByVal) ファイルリストに1ファイル追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListOneFolderEnd FileListEventHandler 値渡し(ByVal) 1フォルダーのファイル取得後に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListEnd FileListEventHandler 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_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 ' ボタンのテキストを設定. 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
Dパス、検索パターン、サブフォルダーの取得有無、取得属性、調査しないフォルダー属性を指定してファイルリストを取得します。 構文:Public Function GetFileList( Path , SearchPattern , SubFolder , Attributes , NotAttributes , NotCheckFolderAttributes , Event_GetFileListOneAdd , Event_GetFileListOneFolderEnd , Event_GetFileListOneAllFolderEnd , Event_GetFileListEnd ) As Boolean
引数:
名前 型 引数渡しの方法 説明 Path String 値渡し(ByVal) ファイルリストを取得するフォルダのフルパスを渡します。 SearchPattern String 値渡し(ByVal) 検索パターンを渡します。
※複数指定を行うときは、SearchPatterndelimiterで設定している文字で区切ります。
(デフォルトは"|")
例:"*.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_GetFileListOneAdd FileListEventHandler 値渡し(ByVal) ファイルリストに1ファイル追加された時に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListOneFolderEnd FileListEventHandler 値渡し(ByVal) 1フォルダーのファイル取得後に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListOneAllFolderEnd FileListEventHandler 値渡し(ByVal) 1フォルダーのフォルダー取得後に返すイベント関数のアドレスを渡します。
※イベント関数が不要な場合は、Nothingを渡します。Event_GetFileListEnd FileListEventHandler 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.IsGetFileRunning 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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_GetFileList_Collections
構文:Public Function Dispose_GetFileList_Collections() As Boolean
機能:GetFileList用のCollectionsを解放します。
引数:なし。
戻り値:Boolean
戻り値の説明:
True:成功 False:失敗
使用例:
NSDFile内で使用されるので使用例はありません。
●NSDFile(GetFileListで使用する)イベントの説明
名前:Event_GetFileListOneAdd
構文:Public Sub Event_GetFileListOneAdd( sender , e )
機能:ファイルリストに1ファイル追加された時に発生するイベント。
※GetFileListの引数にアドレスを渡します。
引数:
名前 型 引数渡しの方法 説明 sender Object 値渡し(ByVal) Nothingが渡されます。 e NSDFileFolderListEventArgs 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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_GetFileListOneFolderEnd
構文:Public Sub Event_GetFileListOneFolderEnd( sender , e )
機能:1フォルダーのファイル取得後に発生するイベント。
※GetFileListの引数にアドレスを渡します。
引数:
名前 型 引数渡しの方法 説明 sender Object 値渡し(ByVal) Nothingが渡されます。 e NSDFileFolderListEventArgs 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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_GetFileListOneAllFolderEnd
構文:Public Sub Event_GetFileListOneAllFolderEnd( sender , e )
機能:1フォルダーのフォルダー取得後に発生するイベント。
※GetFileListの引数にアドレスを渡します。
引数:
名前 型 引数渡しの方法 説明 sender Object 値渡し(ByVal) Nothingが渡されます。 e NSDFileFolderListEventArgs 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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_GetFileListEnd
構文:Public Sub Event_GetFileListEnd( sender , e )
機能:ファイルリストの取得終了時に発生するイベント。
※GetFileListの引数にアドレスを渡します。
引数:
名前 型 引数渡しの方法 説明 sender Object 値渡し(ByVal) Nothingが渡されます。 e NSDFileFolderListEventArgs 値渡し(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 ' リストを取得します. Me.ListBox1.Items.Clear Me.Label_ListCount.Text = "取得件数:0" ' ファイルリスト取得. BlnCls_GetFileFolder = Cls_File.GetFileList(Me.TextBox1.Text, _ Me.TextBox_SearchPattern.Text, _ True , _ 0, _ 0, _ IO.FileAttributes.System , _ AddressOf GetFileListOneAdd_Callback, _ AddressOf GetFileListOneFolderEnd_Callback, _ AddressOf GetFileListOneAllFolderEnd_Callback, _ AddressOf GetFileListEnd_Callback) If BlnCls_GetFileFolder Then Me.Button_GetFile.Text = "中止" Else MsgBox("リストが取れません。") End If Case True ' リストの取得を中止します. Me.Button_GetFile.Text = "リストの取得" Cls_File.StopGetFileList = 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.FileInfo = .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 : ' ファイルのフルパス名だけ必要な場合は、AddPathで取得できます. Dim Str_FileName As String = e.AddPath : End With Catch ex As Exception End Try End Sub ' 1フォルダーのファイル取得後に呼び出されるイベント関数. Private Sub GetFileListOneFolderEnd_Callback(ByVal sender As Object, _ ByVal e As NSDFile.NSDFileFolderListEventArgs) Try : Catch ex As Exception End Try End Sub ' 1フォルダーのフォルダー取得後に呼び出されるイベント関数. Private Sub GetFileListOneAllFolderEnd_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 ' ボタンのテキストを設定. 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.