我想在程序中保存设置,如下所示。 我有一个导入按钮来打开文件。当我下次启动我的程序时,我怎么能这样做,它们已经被“导入”作为一个设置或什么? *注意 - 我没有尝试任何东西,因为我没有丝毫的线索如何。
答案 0 :(得分:0)
执行导入时,代码将执行类似将所有文件名写入文本文件的操作。然后在每次执行程序时读取文本文件并检查任何内容。您可能需要修改代码以适合您的程序
Private Const MySetting As String = "MySetting.txt"
Private Sub Log_into_File(ByVal Filenames() As String)
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWriter = oFile.OpenText(MySetting)
For Each FName As String IN Filenames
oWrite.WriteLine(FName & VbCrLF)
Next
oWriter.Close()
End Sub
Private Function Is_Imported() As Boolean
Dim EntireFile As String
Dim oFile As System.IO.File
Dim oReader As System.IO.StreamReader
oReader = oFile.OpenText(MySetting)
EntireFile = oRead.ReadToEnd()
oRead.Close()
Return Trim(Replace(EntireFile, VbCrLF, "")).Equals(String.Empty)
End Function