Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub FixRegInfoDir()
- 'Sync dirs to number of registers
- 'Remove if register does not exist or add if needed
- 'Get the current list of dirs
- Dim ListOfRegInfo As List(Of String) = IO.Directory.GetDirectories("c:\iris\reginfo").ToList
- Dim AddRegInfoDir As New List(Of Integer)
- Dim RemoveRegInfoDir As New List(Of Integer)
- 'Loop the list and remove directory and from the list if not needed anymore
- For xLoop As Integer = ListOfRegInfo.Count - 1 To 0 Step -1
- If Not (ListOfRegInfo(xLoop).ToLower.Contains("common") OrElse IO.Path.GetFileName(ListOfRegInfo(xLoop)).ToLower.Contains("reg")) Then
- IO.Directory.Delete(ListOfRegInfo(xLoop), True)
- ListOfRegInfo.RemoveAt(xLoop)
- End If
- Next
- 'Loop the directories and if dir not found add to "add list"
- For xLoopRegisters As Integer = 0 To PosMaint.RegisterInformations.Count - 1
- Dim FoundOne As Boolean = False
- For xLoopDirectories As Integer = 0 To ListOfRegInfo.Count - 1
- If ListOfRegInfo(xLoopDirectories).ToLower.Contains("reg" & PosMaint.RegisterInformations(xLoopRegisters).RegisterNumber.ToString) Then
- FoundOne = True
- End If
- Next
- If Not FoundOne Then
- AddRegInfoDir.Add(PosMaint.RegisterInformations(xLoopRegisters).RegisterNumber)
- End If
- Next
- For xLoopDirectories As Integer = 0 To ListOfRegInfo.Count - 1
- Dim FoundOne As Boolean = False
- For xLoopRegisters As Integer = 0 To PosMaint.RegisterInformations.Count - 1
- If ListOfRegInfo(xLoopDirectories).ToLower.Contains("reg" & PosMaint.RegisterInformations(xLoopRegisters).RegisterNumber.ToString) Then
- FoundOne = True
- End If
- Next
- If (Not FoundOne) AndAlso
- (Not ListOfRegInfo(xLoopDirectories).ToLower.Contains("common")) AndAlso
- (Not ListOfRegInfo(xLoopDirectories).ToLower.Contains("reg1")) Then
- RemoveRegInfoDir.Add(CIntNull(ListOfRegInfo(xLoopDirectories).Substring(ListOfRegInfo(xLoopDirectories).Length - 1, 1)))
- End If
- Next
- 'Add Directories
- For xLoop As Integer = 0 To AddRegInfoDir.Count - 1
- My.Computer.FileSystem.CopyDirectory("C:\IRIS\Reginfo\reg1", "C:\IRIS\Reginfo\reg" & AddRegInfoDir(xLoop).ToString, True)
- Using Appini As New PrivateIniFile("C:\IRIS\Reginfo\reg" & AddRegInfoDir(xLoop).ToString & "\ini\appini.ini")
- Appini.WriteInteger("POS", "REGNUM", AddRegInfoDir(xLoop))
- End Using
- Next
- 'Remove Directories
- For xLoop As Integer = 0 To RemoveRegInfoDir.Count - 1
- IO.Directory.Delete("C:\IRIS\Reginfo\reg" & RemoveRegInfoDir(xLoop), True)
- Next
- 'PE 12/2/2019
- 'Add a check for Modules.ini. Actually, just blind copy it.
- ListOfRegInfo = IO.Directory.GetDirectories("c:\iris\reginfo").ToList
- For xLoop As Integer = 0 To ListOfRegInfo.Count - 1
- If ListOfRegInfo(xLoop).ToLower.Contains("common") Then Continue For
- IO.File.Copy("c:\iris\ini\modules.ini", IO.Path.Combine(ListOfRegInfo(xLoop), "ini", "modules.ini"), True)
- Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement