What code do I need to set a file in a parent folder to a variable?
ex:
App is in the “/Test” folder and the item I need to access is in “/”
What code do I need to set a file in a parent folder to a variable?
ex:
App is in the “/Test” folder and the item I need to access is in “/”
You could use
Dim f As FolderItem = GetFolderItem(“blah”)
Dim s As String = f.AbsolutePath
Then get rid of the last \test to have the path of the Parent to your app
I did this:
Dim f As FolderItem = GetFolderItem("").Parent
Dim s As String = f.AbsolutePath
f = GetFolderItem(s + "file I want")
Thanks.
Faster :
Dim f As FolderItem = GetFolderItem("").Parent.child("file I want")
Admitting the file is indeed above the folder where the app is installed.
[quote=260629:@Charles Fasano]I did this:
Dim f As FolderItem = GetFolderItem("").Parent
Dim s As String = f.AbsolutePath
f = GetFolderItem(s + "file I want")
Thanks.[/quote]
Yeah dont do that
This gives you the same item
Dim f As FolderItem = GetFolderItem("file I want")
[quote=260632:@Norman Palardy]Yeah dont do that
This gives you the same item
Dim f As FolderItem = GetFolderItem("file I want")
No it doesn’t. The file doesn’t exist in the same folder as the app. It exists in the previous folder.
I need “/File.txt” not “/Test/File.txt” and the app is in “/Test”
See Michael’s response Norman’s response was to a quick read of the question Parent & Child always confuse me so I just go with the path
GetFolderItem always puts you in the app directory if you don’t include a path. So to back up 1 directory with the name of the file you’re trying to get is Michael’s method.
please don’t mess with AbsolutePath. Use Parent and Child functions.
I come from the old age when we used path, but Xojo made me embrace the notion of folderitem parent and child, because they are perfectly cross-platform. Besides, if I still want to see the path, it is just a shellPath away.