Advertisement
penright

Untitled

Oct 3rd, 2023
1,429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.29 KB | None | 0 0
  1.  Sub FixRegInfoDir()
  2.  
  3.         'Sync dirs to number of registers
  4.         'Remove if register does not exist or add if needed
  5.         'Get the current list of dirs
  6.         Dim ListOfRegInfo As List(Of String) = IO.Directory.GetDirectories("c:\iris\reginfo").ToList
  7.         Dim AddRegInfoDir As New List(Of Integer)
  8.         Dim RemoveRegInfoDir As New List(Of Integer)
  9.         'Loop the list and remove directory and from the list if not needed anymore
  10.         For xLoop As Integer = ListOfRegInfo.Count - 1 To 0 Step -1
  11.             If Not (ListOfRegInfo(xLoop).ToLower.Contains("common") OrElse IO.Path.GetFileName(ListOfRegInfo(xLoop)).ToLower.Contains("reg")) Then
  12.                 IO.Directory.Delete(ListOfRegInfo(xLoop), True)
  13.                 ListOfRegInfo.RemoveAt(xLoop)
  14.             End If
  15.  
  16.         Next
  17.         'Loop the directories and if dir not found add to "add list"
  18.         For xLoopRegisters As Integer = 0 To PosMaint.RegisterInformations.Count - 1
  19.             Dim FoundOne As Boolean = False
  20.             For xLoopDirectories As Integer = 0 To ListOfRegInfo.Count - 1
  21.                 If ListOfRegInfo(xLoopDirectories).ToLower.Contains("reg" & PosMaint.RegisterInformations(xLoopRegisters).RegisterNumber.ToString) Then
  22.                     FoundOne = True
  23.                 End If
  24.             Next
  25.             If Not FoundOne Then
  26.                 AddRegInfoDir.Add(PosMaint.RegisterInformations(xLoopRegisters).RegisterNumber)
  27.             End If
  28.         Next
  29.         For xLoopDirectories As Integer = 0 To ListOfRegInfo.Count - 1
  30.             Dim FoundOne As Boolean = False
  31.             For xLoopRegisters As Integer = 0 To PosMaint.RegisterInformations.Count - 1
  32.                 If ListOfRegInfo(xLoopDirectories).ToLower.Contains("reg" & PosMaint.RegisterInformations(xLoopRegisters).RegisterNumber.ToString) Then
  33.                     FoundOne = True
  34.                 End If
  35.             Next
  36.             If (Not FoundOne) AndAlso
  37.                 (Not ListOfRegInfo(xLoopDirectories).ToLower.Contains("common")) AndAlso
  38.                 (Not ListOfRegInfo(xLoopDirectories).ToLower.Contains("reg1")) Then
  39.                 RemoveRegInfoDir.Add(CIntNull(ListOfRegInfo(xLoopDirectories).Substring(ListOfRegInfo(xLoopDirectories).Length - 1, 1)))
  40.             End If
  41.         Next
  42.         'Add Directories
  43.         For xLoop As Integer = 0 To AddRegInfoDir.Count - 1
  44.             My.Computer.FileSystem.CopyDirectory("C:\IRIS\Reginfo\reg1", "C:\IRIS\Reginfo\reg" & AddRegInfoDir(xLoop).ToString, True)
  45.             Using Appini As New PrivateIniFile("C:\IRIS\Reginfo\reg" & AddRegInfoDir(xLoop).ToString & "\ini\appini.ini")
  46.                 Appini.WriteInteger("POS", "REGNUM", AddRegInfoDir(xLoop))
  47.             End Using
  48.         Next
  49.         'Remove Directories
  50.         For xLoop As Integer = 0 To RemoveRegInfoDir.Count - 1
  51.             IO.Directory.Delete("C:\IRIS\Reginfo\reg" & RemoveRegInfoDir(xLoop), True)
  52.         Next
  53.  
  54.         'PE 12/2/2019
  55.         'Add a check for Modules.ini. Actually, just blind copy it.
  56.         ListOfRegInfo = IO.Directory.GetDirectories("c:\iris\reginfo").ToList
  57.         For xLoop As Integer = 0 To ListOfRegInfo.Count - 1
  58.             If ListOfRegInfo(xLoop).ToLower.Contains("common") Then Continue For
  59.             IO.File.Copy("c:\iris\ini\modules.ini", IO.Path.Combine(ListOfRegInfo(xLoop), "ini", "modules.ini"), True)
  60.         Next
  61.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement