Determining File Path

I’m new to this and new help to figuring out how to point to the file “HCPref2” in a folder “HC Prefs Folder 2” on the Desktop.

Var myFile As FolderItem
Var b As BinaryStream
myFile = Desktop/HC Prefs Folder 2/HCPref2
If myFile <> Nil Then
b = BinaryStream.Open(myFile)
mainWindow.TextArea1.Value = b.Read(b.Length)
b.Close
End If

[code]dim myFile as folderitem = specialfolder.desktop.child(“HC Prefs Folder 2”)
if myFile = nil or not myFile.exists then return 'or make error message
myFile = myFile.child(“HCPref2”)
if myFile = nil or not myFile.exists then return 'or make error message

dim b as BinaryStream
try
b = BinaryStream.open(myFile)
catch err as IOException
'do some error handling here
end try[/code]

I see you have done error checking on each step which is great. I should do that.

I found this was what I needed which is the same thing you are doing without error checking:

myFile = SpecialFolder.Desktop.Child (“HC Prefs Folder 2”).Child( “HCPref2” )

Thanks for the quick reply and suggestions.

Other(s) examples here .

Also:
http://documentation.xojo.com/api/files/specialfolder.html
http://documentation.xojo.com/api/files/folderitem.html

At last, read See Also entries at each page’s bottom.