I am still new and learning Xojo so any help would be appreciated. I am currently working on a project where I create a PDF and then that pdf needs to be saved to a specific path on the desktop(same for all users). I currently have this code below which saves it to the desktop. How would I go about modifying this I can specify the exact path I want the file to be saved to rather than just my local desktop?
Var f As FolderItem = SpecialFolder.Desktop.Child(“doc.pdf”)
doc.Save(f)
f.Open
The path is a network path in which it is shared across multiple desktops. The path is “\m20\Engineering\Release Documents” in which m20 is the machine. As of right now, I am just testing to make sure it saves to that path, and then I am going to work on unique file name generation for additional files that are going to be automatically generated to this folder.
You may want to consider setting the basic path when opening the application and possibly even saving the path in a preference file. If you use a FolderItem variable in a module or in the main App it will make your save routine not to have to get the FolderItem each time you need to save a new file.
Var f As FolderItem
f = New FolderItem("\m20\Engineering\Release Documents\", FolderItem.PathModes.Native)
If <> Nil
If f.Exists Then
DefaultPath = f
Else
// do something to handle the fact that The path doesn't exist
End If
Else
// handle the Nil object
End If
Then just use the default path folderitem when saving: DefaultPath.Child(“yourfilename”)
It doesn’t check if it exists so you’d need to add code to make sure it’s there, but you can put the folder name as a child, like: Var f As FolderItem = SpecialFolder.Desktop.Child("FolderName").Child(“doc.pdf”)