Xojo telling me change a deprecated item

When I check for errors Xojo is telling me to change the line that reads:
pName = f.AbsolutePath (to)
pName = f.NativePath

Yet when I do this I get a IOException error and my program crashes! - WHATS GOING ON?

(By the way - Its a routine that lets the user select a CSV file, parses it, then puts the contents in a Listbox)
Heres the code if anybody is interested…
1 X Button called PushButton1 - 1 X Listbox called ListBox1 - 1 X Method called ImportList (parameters - FileName As String,FilePath As String,LstBox As ListBox)

PushButton1 Action:

Dim dlg as OpenDialog
Dim f as FolderItem
Dim fName,pName As String
dlg=New OpenDialog
dlg.InitialDirectory = Volume(0).Child(“Desktop”)
dlg.Title = “Select a CSV text file”
dlg.Filter = “Text Documents (*.txt)” // file type defined in File
f=dlg.ShowModal()
If f <> Nil then
fName = f.Name
pName = f.AbsolutePath //THIS WORKS !!
//pName = f.NativePath //THIS DOESN’T WORK AND SO IS COMMENTED OUT?
ImportList(fName,pName,Window1.ListBox1)
Else
//User Cancelled
exit
End if

Method ImportList Code:

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

count = LstBox.ColumnCount
LstBox.DeleteAllRows
f = GetFolderItem(FilePath)
If f <> Nil then // check to make sure the file exists
TextIn = TextInputStream.Open(f)
If TextIn <> NIL Then
Do
// read a line
line = TextIn.ReadLine
// add a row in the listbox
LstBox.AddRow “”
For i = 1 To count
// read the data
c = NthField(line,Chr(44),i)
r = LstBox.LastIndex
// strip off the enclosing quotes
x = Len©
s = Mid(c,1,(x))
// put the data in the cell
LstBox.Cell(r,(i-1)) = s
Next
Loop Until TextIn.EOF = True
End If
Else
// error message
MsgBox "Error Reading input file: " + FileName
End If

In your ImportList code, the line that says

f = GetFolderItem(FilePath)

You really should be telling it what kind of path you’re passing. If you’re using AbsolutePath, it should be:

f = GetFolderItem(FilePath,FolderItem.PathTypeAbsolute)

if NativePath:

f = GetFolderItem(FilePath,FolderItem.PathTypeNative)

Not specifying means the function has to guess.

OK I understand that explanation - Thanks Greg

I don’t understand that explanation and, so, want to stir the pot. Your original question, Stuart, involved the first part of your code where you claim that .nativepath doesn’t work. I ran the following code (with the noted changes) and the full path to my file displayed correctly in the msgBox. I think something else is wrong with your code.

Dim dlg as OpenDialog Dim f as FolderItem Dim fName,pName As String dlg=New OpenDialog //dlg.InitialDirectory = Volume(0).Child("Desktop") dlg.InitialDirectory = SpecialFolder.Desktop dlg.Title = "Select a CSV text file" //dlg.Filter = "Text Documents (*.txt)" // file type defined in File dlg.Filter = FileTypes1.Text f=dlg.ShowModal() If f <> Nil then fName = f.Name 'pName = f.AbsolutePath //THIS WORKS !!: Clary: but is deprecated pName = f.NativePath //THIS DOESN'T WORK : Clary: It does for me 'ImportList(fName,pName,Window1.ListBox1) MsgBox pName Else //User Cancelled exit End if

Xojo 2014 r1.1
Mac 10.9

The error is in his IMPORTLIST procedure (which you did not execute)
and for which he did not provide the Signature, but is passing in a STRING version of the folder path.

Because in the original code he is passing in a deprecated ABSOLUTEPATH, the line

f = GetFolderItem(FilePath)

fails because a proper path TYPE was not specified
if you make the change the you have indicated as “works” [nativepath]
then the line above must be

f = GetFolderItem(FilePath,FolderItem.PathTypeNative)

Why convert the FolderItem to a path and then back to a FolderItem again? Just have ImportList accept a FolderItem as its first parameter and pass it the result from the OpenDialog (dlg.ShowModal).