ClassIOException Error

Below is a section of code that is producing this exception error: “An exception of classIOException was not handled. The application must shut down. Exception error number 2”. It appears that the culprit is “LicFileStream = TextInputStream.Open(LF)” when attempting to open a license text file when it does not exist yet. I intended the “If LF <> Nil Then” statement to bypass but it appears to be ineffective. What am I missing?

//Read and validate the license file in program folder
Dim LF as FolderItem
Dim LicFileStream as TextInputStream
Dim QAKey as String
Dim HWKey as String
Dim LicenseKey as String
Dim Status as Boolean = False

LF = SpecialFolder.CurrentWorkingDirectory()
LF = LF.Child(“QALF.txt”)

If LF <> Nil Then

LicFileStream = TextInputStream.Open(LF)
QAKey = LicFileStream.ReadLine
LicenseKey = LicFileStream.ReadLine
LicFileStream.Close

HWkey = GuancheID.GetHWIDKey

Status = guancheMOS.verify(True,QAKey,HWKey,"-----------",LicenseKey)

End If

Return Status

Your code will always have a valid object, check if it exists

http://documentation.xojo.com/api/files/folderitem.html.Exists