Hello everyone,
I’m testing my software in Linux (it works in Windows). I’d like to open an .ods file from my software in Linux. Something’s wrong with the path because I can’t open it… but I don’t understand what. It’s a network path. Any advice?
This uses escaped spaces (\ ), which are only necessary in terminal commands or shell scripts — not in file paths used in Xojo or general programmatic contexts.
Try this one instead:
"/run/user/1000/gvfs/smb-share:server=192.168.1.4,share=desktop/H&F UTILITA'/Listini ed Elenchi/Costo Materiali-Listino al cliente Excel.ods"
Verify That GVFS Is Mounted
Use a FolderItem
Var f As FolderItem
f = New FolderItem("/run/user/1000/gvfs/smb-share:server=192.168.1.4,share=desktop/H&F UTILITA'/Listini ed Elenchi/Costo Materiali-Listino al cliente Excel.ods", FolderItem.PathModes.Native)
If f.Exists Then
// Proceed to open the file
Else
MessageBox("File not found: " + f.NativePath)
End If
If you just want to open the file using the default system app:
Var sh As New Shell
sh.Execute("xdg-open " + f.ShellPath)
Non-ASCII characters (like accents or apostrophes) in folder names can lead to issues.
What behavior are you seeing? Does the OpenDocument event occur? Does the FolderItem it provides exist? Is it nil? Are you getting a RuntimeException or a Crash?
What is the code you are using that doesn’t work, and in what way doesn’t it work?
My code is: Var f As new FolderItem (LeggiRigoFileDiTesto(4), FolderItem.PathModes.Native)
If f <> Nil Then
if f.Exists then
f.Open
else
messagebox " Attenzione, probabilmente il file " + LeggiRigoFileDiTesto(4) +" non esiste …"
end if
Else // User Cancelled
messagebox “Attenzione … il rigo n°4 del file di configurazione presenta un errore nella path ‘’ " +LeggiRigoFileDiTesto(4) +” ‘’"
End If
LeggiRigoFileDiTesto(4) is a Method that read a 4° row,which reads the 4th line of my text file, the one where I recorded the program path. In Windows is: /* RIGO 4*/\PCUFFICIO\Desktop\H&FUTI~1\LISTIN~1\COSTOM~1.ODS/* qui si memorizza la Path del listino prezzi xls, o ods*/ From your laptop, the path should be:/run/user/1000/gvfs/smb-share:server=192.168.1.4,share=desktop/H&F\ \ UTILITA’/Listini\ ed\ Elenchi/Costo\ Materiali-Listino\ al\ cliente\ Excel.ods but evidently something is not working
I also tried with the path: smb://192.168.1.4/desktop/H&F%20%20UTILITA’/Listini%20ed%20Elenchi/Costo%20Materiali-Listino%20al%20cliente%20Excel.ods
The file is on a PC on my network with IP 192.168.1.4, from the PC with Linux I can open the file from the Windows Explorer, but not from Xojo. Maybe the way to open a file changes? Or am I writing the file’s path incorrectly? I don’t get a specific error, just the warning message from my code that the file isn’t found, so it says f=nil.
I definitely think the fact that this is a smb-share link is why it’s not resolving to a FolderItem. How you might get a FolderItem for a smb-share is not something I’m familiar with, I’m sorry.
As a debugging + info collecting step you could try selecting the file with a file selector. The resulting FolderItem might have some useful information towards being able to reconstruct one.
var dlg as new OpenFileDialog
var f as FolderItem = dlg.ShowModal
break
The resulting path is:
/run/user/1000/gvfs/smb-share:server=192.168.1.4,share=desktop/H&F UTILITA’/Listini ed Elenchi/Costo Materiali-Listino al cliente Excel.ods If I type this path in the navigation bar, it opens the file on the remote PC. If I type it in the txt file and try to open it from Xojo, the file is not found. What’s the problem?
I test path:
smb://192.168.1.4/desktop/H&F%20%20UTILITA’/Listini%20ed%20Elenchi/Costo%20Materiali-Listino%20al%20cliente%20Excel.ods
and
/run/user/1000/gvfs/smb-share:server=192.168.1.4,share=desktop/H&F UTILITA’/Listini ed Elenchi/Costo Materiali-Listino al cliente Excel.ods .
Something’s wrong with the path, but I can’t figure out what. Is the xojo method for opening the file with the associated program the same for all operating systems? ( Var f As new FolderItem (LeggiRigoFileDiTesto(4), FolderItem.PathModes.Native)
If f <> Nil Then
if f.Exists then
f.Open…)
So… one of the issues that you’re running into here is your belief that the windows on the desktop where you’re pasting these paths are just processed as a file. They’re not.
The path that starts with SMB:// is a URL and to convert it you’ll need to run URLDecode and then make it a folderitem using PathModes.URL instead of NativePath.
The other path is a GVFS (GNOME Virtual File System) URI which doesn’t even work with common commands like ls and cat unless accessed via GVFS-aware tools like gio, gvfs-ls, gvfs-cat, etc. I doubt that Xojo would know what to do with that at all. You might be able to use the gvfs shell commands to mount the drive and give you a usable path though.
That doesn’t surprise me at all. Since the path you have includes a mountpoint, the OS needs to actually do the mounting of the drive. It looks like you can do that using gio
I spent the afternoon figuring out how to mount the shared folder… I did it, now the path is simpler: home/Noeli/Scrivania/Desktop and here I pasted an .ods file called test.ods, so the complete mounted path is home/Noeli/Scrivania/Desktop/test.ods but I still can’t open it. I don’t get any errors, but I can’t open it.
You seem to be missing something at the front of that path. “home” is relative you your CWD, which is going to be different in a running xojo program than at the shell prompt.
I tried typing the path directly from the code, and it gets to the file’s opening point, but it doesn’t open it. Again, it works fine in Windows, but not in Linux. If I click on the network file, it opens it, so the OpenOffice Calc program is associated with the .ods file… why doesn’t it open with .open?
Var f As new FolderItem (“/home/Noeli/Scrivania/desktop/test.ods”, FolderItem.PathModes.Native)
If f <> Nil Then
if f.Exists then messagebox “OPEN FILE”
f.Open
else
messagebox " FILE NOT EXIST"
end if
Else // User Cancelled
messagebox “Path error in config file’”
End If
I tried opening a .txt file (thinking it would be smaller) but it still gets to the opening point but doesn’t open it.