TextInputStream Empty?

Am I doing something stupid here? I cannot fathom out why ReadAll doesn’t retrieve anything. The file exists, it’s length is also reported under FolderItem. I am running this on Ubuntu, and if i ‘cat’ the file as a standard user the the content is displayed.

The code executes without error, byt strMTAB is empty.

Var f As FolderItem
Var strMTAB As String

If TargetLinux Then
  
  f = New FolderItem("/etc/mtab", FolderItem.PathModes.Shell, False)
  
End If


If f.Exists = True Then
  
  Var t As TextInputStream
  
  Try
    
    t = TextInputStream.Open(f)
    t.Encoding = Encodings.UTF8
    strMTAB = t.ReadAll
    t.Close
    
    If strMTAB.IndexOf(frmMain.SFTPDestinationServer) > 0 Then
      
      Return True
      
    Else
      
      Return False
      
    End If
    
  Catch e As IOException
     
     t.Close
     MsgBox("Error accessing file.")
     
  End Try
  
End If

Examine the file in a hex editor.
Does it have a character 0 or 26 right at the start of the file?

Hi Jeff, it has a zero.

image

No, it starts with 73 hex.
I was wondering if it was cutting off early

This is a special file in Linux. If you’re hell bent on opening it, you need to use a read-only binary stream.