I’m playing with some code I modified to save my serial port preferences. I have used this code before. If there is no folder and it gets to the line “If prefFolder <> Nil then” it will continue and give a IOException 2. When I examined the preFolder value, it says Nil.
What’s going on?
Var prefFolder As FolderItem
#If DebugBuild Then
prefFolder = SpecialFolder.Desktop.Child(“Pbo3pText”)
#Else
prefFolder = SpecialFolder.ApplicationData.Child(“Pbo3pText”)
#Endif
If prefFolder <> Nil then
Var prefFile As FolderItem = prefFolder.Child(“Pbo3pText.json”)
Var tis As TextInputStream tis = TextInputStream.Open(prefFile)
Var prefs As JSONItem prefs = New JSONItem(tis.ReadAll) tis.Close
SerialPortTesterName = prefs.Value(“SerialPortTester”)
SerialPortGeneratorName = prefs.Value(“SerialPortGenerator”)
End If
2 posts - 2 participants