Am I missing something or what…
I usually store files in a database as path reference. I use the NativePath value of a FolderItem object.
But I would rather refer to a relative path. My database is a project file. In my project, I point to media resources needed in my project.
But, as I backup my project, I usually copy (or move) the project along with the resource files to a new (remote) location. As long I keep my project’s folder structure intact, everything should be working fine.
Since I store files with the NativePath value, they keep pointing to a place where the resources no longer reside.
Is there already a way to get a FolderItem that is relative to another one?
myReSource = "../VideoFiles/myVideo.mxf"
myOtherResource = "../MetaData/someMetaData.xml"
dim myResource as folderItem = getFolderItem("").child("VideoFiles").child("myVideo.mxf")
And you can use folderItem.GetSaveInfo which is relative http://documentation.xojo.com/index.php/FolderItem.GetSaveInfo
But getFolderItem("") will return the Executable’s parent-folder, right?
I don’t want that. When I open a project (the SQLite Database), the resource files will need to be relative to that project file, not the application.
Of course, it needs to go both ways: getting a relative path and setting a relative:
// projectFile is a FolderItem property in some Class
// myVideoFile is a FolderItem of a resource video file
' this should return "../VideoFiles/myVideo.mxf"
dim myResourcePath as string = projectFile.RelativePath( myVideoFile )
' this should return the actual FolderItem of the relative path
dim myResourceFile as FolderItem = projectFile.RelativeItem( "../VideoFiles/myVideo.mxf" )
I was just wondering if this already exists in Xojo. I just can’t find it. Otherwise, I would make my own.
Edwin, how can I guess what …/ meant ?
If you care to try and understand what GetSaveInfo is all about, that should fit perfectly what you need. And dump these outdated paths. That will help a lot.
Dont do that.
Create a folder for your files in ApplicationData, in a folder named for your app.
Then you can use
myReSource = specialfolder.applicationdata.child(“MyApp”).child(“myVideo.mxf”)
This works where ever your app is, even if it is running in debug mode.
I think he means a “project file” like a Xojo project and resources for that project will be relative to it
So if what is stored is VideoFiles/myVideo.mxf
and the path to the project file is known
then the file would be
The delimiter here is a slash, but could just as easily be any character… the trick is just to split the relative folders that were stored and turn them into successive .child references?