xojo build not running like Real Studio build

I originally built a desktop application using Real Studio (final version) which works fine.
The application has an option to import a CSV file into a Listbox which works very well when built with Real Studio
When I open the file and then compile the same app with Xojo and try importing the same CSV file I get:

An exception of class IOException was not handled.
The application must shut down. Exception Error Number: 2

The CSV parse function looks ok and works well in Real Studio - I can’t see what it could be…
Any idea what this exception even means?

I’m running Xojo 3.1 on a MAC running Mavericks 10.9.2

Put a breakpoint in and follow it in the debugger. What do you see there?

OK - this is the breakpoint line:
Textln = TextInputStream.Open(f)
Where f is a FolderItem (the CSV files name and path) and Textln is a TextInputStream

Here’s the CSV parsing code that works fine in Real Studio

Dim f as FolderItem
Dim TextIn As TextInputStream
Dim count,i,r, x As Integer
Dim line,c,s As String

count = List.ColumnCount
List.DeleteAllRows
f = GetFolderItem(FilePath)
If f <> Nil then // check to make sure the file exists
//TextIn = f.OpenAsTextFile
TextIn = TextInputStream.Open(f)
If TextIn <> NIL Then
Do
// read a line
line = TextIn.ReadLine
// add a row in the listbox
List.AddRow “”
For i = 1 To count
// read the data
c = NthField(line,Chr(44),i)
r = List.LastIndex
x = Len©
s = Mid(c,1,(x))

      //To strip off any enclosing quotes use this instead
      //s = Mid(c,2,(x-2))
      
      // put the data in the cell
      List.Cell(r,(i)) = s
    Next
  Loop Until TextIn.EOF = True
End If

Else
// error message
MsgBox "Error Reading input file: " + FileName
End If

Its a CSV parsing routine I got from Monkey Bread Software (Tom Dixon)

What does “f” point to? Is it a valid file? An IOException like this typically indicates the file cannot be accessed (permissions) or perhaps isn’t available. Or perhaps it is open by another app and is locked?

Just wanted to ask the same :slight_smile:

I’m partial to If f.Exists Then to check if the file is actually there myself.

Difference between Folderitem.exists and folderitem <> nil:

f <> nil means that the path is correct (and there could be a file at the end of the path!)
f.exists should be used to know if the file exists on the volume.

Let say you want to create a file MyFile.

f=getfolder(“pathtomyfile:myfile”)

f is not nil, but f.exists is false (unless myfile soon exists in the folder).

And please, don’t call your ListBox “List”. This is just bound to cause problems at some point. Call it LB or lb or LB_Data or …

OK figured it out…Heres the import button code
The line that reads
pName = f.AbsolutePath
used to be…
pName = f.NativePath
I changed it to this because Xojo was telling me that it was a depreciated item.

ImportList is a method that contains a parse routine for the CSV file

Dim dlg as OpenDialog
Dim f as FolderItem
Dim fName,pName As String

dlg=New OpenDialog
dlg.InitialDirectory= SpecialFolder.Desktop
dlg.Title = “Select a CSV text file”
dlg.Filter = “Text Documents (*.csv)” // file type defined in File
f=dlg.ShowModal()
If f <> Nil then
fName = f.Name
pName = f.AbsolutePath
ImportList(fName,pName,PasswordGen.ListBox1)
Else
//User Cancelled
exit
End if

Anyway…it works now

You should not be passing around an absolute path like that unless you need to send it to some external process or display it to a human.

Agreed. Pass the folderitem directly.