Insert File
-
I am running a program that search .wav, .wmv, and .mp3 files on the computer and automatically stores them into a database table. The table name is tblFileReport. I have another table called tblExclude which includes files that are excluded. However, I do not want to insert the file into tblFileReport if the file exist in tblExclude. For example, if "ExcludeFileName" is equal to filename then I don't want this file to be added to tblFileReport. But, if the file is not in tblExclude then add the file to tblFileReport. Here is the code that I have so far:
For Each folder As String In paths Try For Each file As String In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchAllSubDirectories, patterns) fileName = System.IO.Path.GetFileName(file).ToLower Insert(file, fileName, CType(IPAddress.AddressList.GetValue(0), Net.IPAddress).ToString, System.Net.Dns.GetHostName) 'End If Next Catch ex As UnauthorizedAccessException End Try Next
The string filename is the name of the file, for example chimes.wav, and if this name is equal to "ExcludeFileName" which is the filename column in tblExclude then do not add to tblFileReoport. I am thinking maybe an If, Then statement needs to be included in this code sample. Any ideas? jds1207 -
I am running a program that search .wav, .wmv, and .mp3 files on the computer and automatically stores them into a database table. The table name is tblFileReport. I have another table called tblExclude which includes files that are excluded. However, I do not want to insert the file into tblFileReport if the file exist in tblExclude. For example, if "ExcludeFileName" is equal to filename then I don't want this file to be added to tblFileReport. But, if the file is not in tblExclude then add the file to tblFileReport. Here is the code that I have so far:
For Each folder As String In paths Try For Each file As String In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchAllSubDirectories, patterns) fileName = System.IO.Path.GetFileName(file).ToLower Insert(file, fileName, CType(IPAddress.AddressList.GetValue(0), Net.IPAddress).ToString, System.Net.Dns.GetHostName) 'End If Next Catch ex As UnauthorizedAccessException End Try Next
The string filename is the name of the file, for example chimes.wav, and if this name is equal to "ExcludeFileName" which is the filename column in tblExclude then do not add to tblFileReoport. I am thinking maybe an If, Then statement needs to be included in this code sample. Any ideas? jds1207