I have a cross platform application that looks for a Config.txt file in the same directory as the application in order to read settings and import them.
My code works great on Windows and macOS, but on Linux I’m “Class IO Exception not handled”: “Exception Error number 2.” This is true even if I move the location of where the app is looking for the Config.txt file, like the desktop. I have some code to check if the file is there or not, and that works correctly on Linux. It’s just when the file is actually there I get the error.
Dim f As FolderItem = GetFolderItem("")
if f <> nil then
f = f.child("Config.txt")
end
if f.Exists=false then
Messagebox ("No Config.txt file found!")
OKQUIT = true
quit
end
Dim t As TextInputStream
t = TextInputStream.Open(f)
dim s as String = t.ReadAll
Dim rg as New RegEx
rg.SearchPattern="####MAXTIME####(.*)####MAXTIME####"
rg.Options.Greedy = False
rg.Options.DotMatchAll = True
Dim myMatch as RegExMatch = rg.search(s)
if myMatch <> nil then
dim configpremax as string
configpremax = trim(myMatch.SubExpressionString( 1 ))
MaxTime = val(configpremax)
t.Close
else
t.Close
end
I’ve also tried the newer folder constructer:
Dim f As new FolderItem("")
if f <> nil then
f = f.child("Config.txt")
end
if f.Exists=false then
Messagebox ("No Config.txt file found!")
OKQUIT = true
quit
end
as well as this:
Var f As New FolderItem("")
f= App.ExecutableFile.Parent.child("Config.txt")
if f.Exists=false then
Messagebox ("No Config.txt file found!")
OKQUIT = true
quit
end
Actually, @Amy_Barnes just recently had an issue accessing a database in the same directory as her Linux web app. @Ricardo_Cruz was on the ticket as well. It’s not currently a “known issue” but two curious cases seems suspicious.
This is not an end-user application, but something that will pushed out with a script. Sort of a fancy pop-up alert screen. The file location is fine and doesn’t need to be modified after the fact. It’s all temporary.
You are correct about the syntax, but alas, did not change the problem.
Huh, okay, the “new” way is what I’ve been using for a while now.
So when I checked the documentation and saw the code I am already using, I was confused.
I already use the “new” way, and have been doing so. So someone’s comment regarding depreciated code posted without inclusion of what the original code used… was confusing to me, as I do not use the previous method of constructing a FolderItem.