Help with WebPicture?

In my app I am loading users that are online for the web app in other sessions… Along with the user, their picture is displayed. Loading their information is going fine but I am having a problem loading up the location of their image and loading it to a web picture so it can display in the listbox. However, I am getting an illegal cast error. Can anybody help with what I am doing wrong? BTW p is a WebPicture. Here is my code:

If sUsersOnline_Usernames.Ubound > -1 Then 
  For i As Integer = 0 To sUsersOnline_Usernames.Ubound
    
    fPictureFolder = GetFolderItem(sUsersOnline_PicturePath(i))
    
    If fPictureFolder <> Nil Then
      If fPictureFolder.Exists And fPictureFolder.IsFolder Then
        fPictureFile = fPictureFolder.Child(sUsersOnline_PictureName(i))
      End If 
    End If 
    
    If fPictureFile <> Nil Then
      If fPictureFile.Exists Then
        p = WebPicture(fPictureFile)
      Else
        p = NoUserImage50
      End If 
    Else
      p = NoUserImage50
    End If 
    
    s=sUsersOnline_Usernames(i) + ", " + EndOfLine
    s=s+sUsersOnline_UserTitle(i) + EndOfLine
    s=s+sUsersOnline_UserSchool(i)
    
    ListBox_UsersOnline.AddRow(sUsersOnline_UserRegID(i),"", s)
    ListBox_UsersOnline.CellPicture(ListBox_UsersOnline.LastIndex, 1) = p
    
  Next
End If

Thanks in advance for help.

try
p = New WebPicture(fPictureFile)
because the Constructor(file as FolderItem)
accept a folderitem as input

That seems to have fixed the illegal cast error. But now I have an IO error 21. LOL. Ill have to research that one now. LOL.

because web run as service does it have permissions to access your files?

I didnt specifically grant permission so I suspect no. This is on the xojo cloud that the files are stored. I will give that a try. Thank you

Okay I changed the permission for the file but still get the same thing. Here is the code.

If bLoginUsersChanged Then
  sUsersOnline_Usernames.SortWith(sUsersOnline_UserRegID, sUsersOnline_UserSchool)
  
  Listbox_UsersOnline.DeleteAllRows
  
  If sUsersOnline_Usernames.Ubound > -1 Then 
    For i As Integer = 0 To sUsersOnline_Usernames.Ubound
      
      fPictureFolder = GetFolderItem(sUsersOnline_PicturePath(i))
      
      If fPictureFolder <> Nil Then
        If fPictureFolder.Exists And fPictureFolder.IsFolder Then
          fPictureFile = fPictureFolder.Child(sUsersOnline_PictureName(i))
          fPictureFile.Permissions = &o777
          
        End If 
      End If 
      
      If fPictureFile <> Nil Then
        If fPictureFile.Exists Then
          p = New WebPicture(fPictureFile)
        Else
          p = NoUserImage50
        End If 
      Else
        p = NoUserImage50
      End If 
      
      s=sUsersOnline_Usernames(i) + ", " + EndOfLine
      s=s+sUsersOnline_UserTitle(i) + EndOfLine
      s=s+sUsersOnline_UserSchool(i)
      
      ListBox_UsersOnline.AddRow(sUsersOnline_UserRegID(i),"", s)
      ListBox_UsersOnline.CellPicture(ListBox_UsersOnline.LastIndex, 1) = p
      
    Next
  End If
  
  bLoginUsersChanged = False
End If 

any ideas? Ive tried searching. I set correctly so Im not sure what could be going on now.

i believe files you not own can only be changed in permissions by super user in linux.
linux have also permissions Groups.
i would make a test window with a button and try to open the file.
i have no experience with xojo cloud.

What folder on Xojo cloud are you placing the pictures in?