FileFlow/Global_Indexer/ModuleUserSavings.vb
2019-11-21 12:11:39 +01:00

70 lines
2.5 KiB
VB.net

Imports System.IO
Module ModuleUserSavings
Public PATH_FileExclusions As String = Path.Combine(Application.UserAppDataPath(), "FileExclusions.xml")
Public Function LoadFileExclusion()
Dim rowresult As String = ""
Try
'if file doesn't exist, create the file with its default xml table
If Not File.Exists(path_FileExclusions) Then
DTEXCLUDE_FILES = CreateExclusionTable()
DTEXCLUDE_FILES.WriteXml(path_FileExclusions)
End If
DTEXCLUDE_FILES = GetTablefromXML()
'For Each Row As DataRow In DT.Rows
' rowresult &= Row.Item("FILE_CONTAIN")
' Select Case Row.Item("FILE_^^CONTAIN")
' End Select
'Next
Return True
Catch ex As Exception
MsgBox("Error in ModuleUserSavings-LoadFileExclusion" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
Return True
End Function
Private Function CreateExclusionTable() As DataTable
Try
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
table.TableName = "TBEXCLUSION"
' Create two columns, ID and Name.
table.Columns.Add("FILE_CONTAIN", GetType(System.String))
Dim newRow As DataRow = table.NewRow()
newRow("FILE_CONTAIN") = "Thumbs"
table.Rows.Add(newRow)
Dim newRow1 As DataRow = table.NewRow()
newRow1("FILE_CONTAIN") = "\~$"
table.Rows.Add(newRow1)
Dim newRow2 As DataRow = table.NewRow()
newRow2("FILE_CONTAIN") = ".db"
table.Rows.Add(newRow2)
Dim newRow3 As DataRow = table.NewRow()
newRow3("FILE_CONTAIN") = "desktop.ini"
table.Rows.Add(newRow3)
table.AcceptChanges()
Return table
Catch ex As Exception
MsgBox("Error in CreateExclusionTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
Private Function GetTablefromXML()
Try
Dim DS As New DataSet
DS.ReadXml(path_FileExclusions)
Return DS.Tables(0)
Catch ex As Exception
MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
End Module