Folder item parent

Var dbFile As New FolderItem("example.sqlite", FolderItem.PathModes.Native)

How do I set the parent of the folder item to data?

TIA

Can you define what you mean by data ?

Language Reference

data is the name of the parent folder that I want that file saved to

Try this:
Var dbFile As New FolderItem(“example.sqlite”, FolderItem.PathModes.Native)
Var dbfileParentS As String = dbfile.Parent.NativePath

You are going to need more than the name “data”, There could be many folders with that name.

You are going to need the full path of the “data” folder that you want.

Then you can use the MoveTo method to move your file to that folder.

1 Like

This does not help. Where in your Volumes is it stored ?

Why ?
Because you may want to set it in a place you do not have the right to write (write permissions), for example. Or an online location, or…

As mentioned above, you can not simply set the Parent of a file to be some other folder. You must obtain a folderitem that represents the new parent, and use .MoveTo on the existing file to ‘put it in that box’
Once there, its parent will have changed

Fwiw this worked fine i just had to go up one more level (parent)

dbFile = new Folderitem(dbFile.Parent.parent.Child(“data”).Child(shop) )

There’s no reason for new FolderItem in that line. Child returns a FolderItem already.

So,… You have a dbfile in this kind of path

abc\
… data\
… def\
… …{dbfile}

and you just set the folderitem called dbfile to point to

abc\
… data\
… …{shop}

That hasnt changed the parent of the dbfile, it has created a new folderitem object in memory, pointing to a file called shop, which may or may not exist.
The original file is still where it was, but you no longer have a handle on it