Well, in my previous thread i needed help deleting arrays, for the codes i use its here: http://www.daniweb.com/software-development/vbnet/threads/426588/how-to-move-arrays-1-place-down-
But now i need help saving the arrays, i can save all the arrays to ini file like this:
Ini module:
Option Strict On
Module INIAccess
#Region "API Calls"
' standard API declarations for INI access
' changing only "As Long" to "As Int32" (As Integer would work also)
Private Declare Unicode Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Int32
Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Int32, _
ByVal lpFileName As String) As Int32
#End Region
Public Function INIRead(ByVal INIPath As String, _
ByVal SectionName As String, ByVal KeyName As String, _
ByVal DefaultValue As String) As String
' primary version of call gets single value given all parameters
Dim n As Int32
Dim sData As String
sData = Space$(1024) ' allocate some room
n = GetPrivateProfileString(SectionName, KeyName, DefaultValue, _
sData, sData.Length, INIPath)
If n > 0 Then ' return whatever it gave us
INIRead = sData.Substring(0, n)
Else
INIRead = ""
End If
End Function
#Region "INIRead Overloads"
Public Function INIRead(ByVal INIPath As String, _
ByVal SectionName As String, ByVal KeyName As String) As String
' overload 1 assumes zero-length default
Return INIRead(INIPath, SectionName, KeyName, "")
End Function
Public Function INIRead(ByVal INIPath As String, _
ByVal SectionName As String) As String
' overload 2 returns all keys in a given section of the given file
Return INIRead(inipath, sectionname, Nothing, "")
End Function
Public Function INIRead(ByVal INIPath As String) As String
' overload 3 returns all section names given just path
Return INIRead(INIPath, Nothing, Nothing, "")
End Function
#End Region
Public Sub INIWrite(ByVal INIPath As String, ByVal SectionName As String, _
ByVal KeyName As String, ByVal TheValue As String)
Call WritePrivateProfileString(SectionName, KeyName, TheValue, INIPath)
End Sub
Public Sub INIDelete(ByVal INIPath As String, ByVal SectionName As String, _
ByVal KeyName As String) ' delete single line from section
Call WritePrivateProfileString(SectionName, KeyName, Nothing, INIPath)
End Sub
Public Sub INIDelete(ByVal INIPath As String, ByVal SectionName As String)
' delete section from INI file
Call WritePrivateProfileString(SectionName, Nothing, Nothing, INIPath)
End Sub
End Module
To save the arrays:
Dim iniPath As String = Application.StartupPath & "\Configs\SilkroadR.ini"
For i = 0 To CurrentAcc.Count - 2
INIWrite(iniPath, "Account " & i, "Version", CurrentAcc(i).Version)
INIWrite(iniPath, "Account " & i, "Login", CurrentAcc(i).Login)
INIWrite(iniPath, "Account " & i, "Username", CurrentAcc(i).Username)
INIWrite(iniPath, "Account " & i, "Password", CurrentAcc(i).Password)
INIWrite(iniPath, "Account " & i, "Character", CurrentAcc(i).Character)
INIWrite(iniPath, "Account " & i, "Server", CurrentAcc(i).Server)
INIWrite(iniPath, "Account " & i, "ReturnLogin", CurrentAcc(i).ReturnLogin)
INIWrite(iniPath, "Account " & i, "LoginStart", CurrentAcc(i).LoginStart)
INIWrite(iniPath, "Account " & i, "RelogDisco", CurrentAcc(i).RelogDisco)
INIWrite(iniPath, "Account " & i, "DisMap", CurrentAcc(i).DisMap)
INIWrite(iniPath, "Account " & i, "SpecialAcc", CurrentAcc(i).SpecialAcc)
Next
Well, i want to save my array to a file that will be encrypted and then i could read it, example when i have my arrays in the application and i save it, i close my application and then i open it again i would like to load all the arrays and all the items in the "DomainUpDown" with a button, which will be read from the file, but i don't want the file to be seen from the users for secure reasons, i would like it to be encrypted.
What i had in mind was saving it as ini file, encrypting the file to another extension, and encrypt it to binary, but to do that i would use the special folder in the AppData, is there a better way for me to save the arrays and encrypt it and be able to read it again and load it in my application ?