How do I open a specific file using TextInputStream. I do not want to use GetOpenFolderItem because if have to select the file manually.
Dim f As FolderItem
Dim textInput As TextInputStream
Dim rowFromFile, oneCell As String
Dim i As Integer
f = GetOpenFolderItem(“text”) //works
// <> Nil And f.Exists Then
Dim tab As String = ChrB(9)
textInput = TextInputStream.Open(f)
textInput.Encoding = Encodings.MacRoman // strings are MacRoman
While Not textInput.EOF
rowFromFile = textInput.ReadLine
LB_Drill.ColumnCount = 2
For i = 1 To CountFields(rowFromFile, “,”)
oneCell = NthField(rowFromFile, “,”, i)
LB_Drill.Cell(LB_Drill.ListCount - 1, i - 1) = oneCell
I am using xojo 2107r3 on windows 7.
[code]f = SpecialFolder.Desktop.Child(filename.txt)
f = getFolderItem(c:\filename.txt, FolderItem.PathTypeNative)[/code]
Either of those…
Could not get either one of them to work. Both generated an error that says “This item does not exist” and at start of string. It highlighted C:\. I checked make sure the file and path was correct, still no luck.
In the example code above, normal " characters have been translated into curly quotes, which are the wrong character.
f = SpecialFolder.Desktop.Child("filename.txt")
Thanks. I got it to work by editing your example file name. I never would have noticed, too small a difference for my eyesight. The quote marks above the apostrophe do not work (next to the return key on my keyboard. Still trying to figure out where the required quotes are located on my keyboard. Must be a ascii key combination.
If you are on a US keyboard the " is located two characters to the right of the “L”, and yes, just to the left of [RETURN]
but you have to press [SHIFT] as well…
Thanks. Works very well now.