Can a folderitem be a string?

I made a string that has a content exactly as a folderitem name:
The string s is:

Volume(Hoofdscherm.V).child(“Meander”).child(“RB”).child(“Klassen”).child(Hoofdscherm.Naamklas).child(Hoofdscherm.Opslagnaam)

These are all properties

When I use it as a folderitem it works fine - i do use some variables. How can I assign it to a foldername, something like

dim f as folderitem
f= Volume(Hoofdscherm.V).child(“Meander”).child(“RB”).child(“Klassen”).child(Hoofdscherm.Naamklas).child(Hoofdscherm.Opslagnaam)

It cannot be done with f.name as far as i can see.
So I wonder:
Is it possible to do this anyway?

When it is not possible I do not need to look further.

Can anyone of you give me some hint? I 'd appreciate your help!

No

Are you trying to read the actual contents of the folder item or are you trying to save the path/location of the folder item as a string?

You can easily do either of those if that’s what you’re looking to do.

I want to read a folder with it. I took folder.Native path, that is a string and i converted it with Nfields to a string like above. That string should be my source and I want to make this to my source folderitem. The target is mostly the same. To give you an idea:
This code is in a dropobjectevent in a Canvas:

If TargetMacOS then
  
  last=CountFields(s,":")
  For i=1 to last
    listbox4.addRow NthField(s,":",i)
    T1.text =T1.text +str(NthField(s,":",i))
    if i > 1 then
      tomx = tomx + ".child(" + str(NthField(s,":",i)) +")"
    end if
  Next
  
  tom2 = tomx
   
end if

REM what I get is .child(Users).child(tomprins).child(Desktop).child(xxxxx.png)
REM and that is in tomx of tom2

tom2 = "Volume(0)" +tom2
//source.name = tom2

The last remark does not work, obviously.

What
I want is that I drag a picture in a Canvas and that this picture is saved automatically. I succeeded with that up to 5 .child items and it worked but is is an awful lot of code. I use listbox4 and T1.text for that

source= Volume(0).child(p3).child(p4).child(p5).child(p6).child(p7)

where p3 and so on are variables written in variables like p6 or whatever.

It works up to 6 variables deep.

I am quite proud on that as a beginner but i suppose it has to be done in an easier way. This code is in a dropobjectevent in a Canvas.

Does this make it clearer?

Thanks in advance…

You want to save the picture or the path to the picture ?
What you’re showing seems like the path to the picture

Hi, Norman,

I drag a picture to a canvas and I want to save it to a destination
I succeeded
(I n my code the source is called bron
The destination is called doel.
I know that Select Case would have been a better choice than using if then, but ok it works.
msgbox " Verplaats de afbeelding naar het bureaublad en sleep opnieuw!" means put
I am wondering if there is no smarter way and making a folderitem.name out of a string could have been nice , but I do believe you it is not possible, even as my name is Thomas.

This is the code:

If Obj.PictureAvailable then
me.backdrop=obj.picture
Elseif Obj.FolderItemAvailable then
me.backdrop=Picture.Open(obj.FolderItem)
End if

dim p1 as string
dim p2 as string
dim p3 as string
dim p4 as string
dim p5 as String
dim p6 as string
dim p7 as string
dim p8 as string
dim p9 as string
dim p10 as string
dim p11 as string
dim tom as string
dim tom2 as string
dim p21 as string
dim tomx as String
Dim x as integer

dim cw as integer
dim ch as integer
dim last as integer
dim i as integer

dim bron as folderitem

dim doel as folderitem
dim stringteller as string

If Obj.PictureAvailable then
Me.backdrop=Obj.Picture
Canvas2.Width = Obj.Picture.Width
Canvas2.Height = Obj.Picture.Height
elseif Obj.FolderItemAvailable then
Me.backdrop=Picture.Open(obj.FolderItem)

cw = Picture.Open(obj.FolderItem).Width
ch = Picture.Open(obj.FolderItem).Height

Canvas1.width = cw
Canvas1.height  = ch

dim p as string
p = obj.FolderItem.name
 

dim s2 as string
Me.name = obj.FolderItem.AbsolutePath
s2= me.name

Windowverder.Textarea1.text = Windowverder.Textarea1.text + s2+ endofline +endofline
dim f as folderitem

dim ft as FolderItem
Dim file as TextInputStream
 
dim opteller as integer
Dim Wegschrijfnaam as string
Rem Just to give a name 
ft = Volume(V).child("Meander").child("RB").child("telnummer.txt")
file=TextInputStream.Open(ft)
if ft <>nil then
  
  stringteller = str(file.readline)
  
  TN2.text = TN2.text + str(opteller)
  Wegschrijfnaam =   stringteller +"---"+(p)
  
  
  file.close
  Listbox1.addrow  str(Wegschrijfnaam)
end if
REM ====== 
Dim s  as String

tom = s2
s= tom
Windowverder.Textarea1.text = Windowverder.Textarea1.text + "OK" + endofline+ endofline+ endofline
If TargetWin32 then
  
  last=CountFields(s,"\")
  For i=1 to last
    listbox4.addRow NthField(s,"\",i)
    T1.text =T1.text +str(NthField(s,"\",i))
  Next
end if



If TargetMacOS then
  
  last=CountFields(s,":")
  For i=1 to last
    listbox4.addRow NthField(s,":",i)
    T1.text =T1.text +str(NthField(s,":",i))
    if i > 1 then
      tomx = tomx + ".child(" + str(NthField(s,":",i)) +")"
    end if
  Next
  
  tom2 = tomx
  Windowverder.Textarea1.text = Windowverder.Textarea1.text  + tom2 + "   is de bron."   + EndOfLine
end if

tom2 = "Volume(0)" +tom2
//bron.name = tom2

for x = 0 to listbox4.ListCount-1
  Listbox4.cell(x,2)  = str(Listbox4.cell(x,0))
  
next

end if

if last = 6 then

p2 = Listbox4.cell (0,0)
p3 =  Listbox4.cell (1,0)
p4 =  Listbox4.cell (2,0)
p5 =  Listbox4.cell (3,0)
p6=  Listbox4.cell (4,0)
p7 =  Listbox4.cell (5,0)
p21 = p7

bron = Volume(0).child(p3).child(p4).child(p5).child(p6).child(p7)

doel = Volume(V).child("Meander").child("RB").child("Plaatjes2").child(stringteller +"---"+p7)

bron.copyfileto(doel)

p21 = p7
listbox1.addrow (p21)

end if

if last = 5 then

p2 = Listbox4.cell (0,0)
p3 =  Listbox4.cell (1,0)
p4 =  Listbox4.cell (2,0)
p5 =  Listbox4.cell (3,0)
p6=  Listbox4.cell (4,0)
p21 = p6
REM copying
bron = Volume(0).child(p3).child(p4).child(p5).child(p6)

doel = Volume(V).child("Meander").child("RB").child("Plaatjes2").child(stringteller +"---"+p6)


bron.copyfileto(doel)

p21 = p6
listbox1.addrow (p21)

end if

if last >6 Or last <5 then
msgbox " Put the picture on the desktop and drag it to the square"

end if

if last > 10 Or last <4 then

msgbox  " Put the picture on the desktop and drag it to the square"

end if

REM Cruciaal!!
Listbox4.DeleteAllRows

[quote=57273:@Tom Prins]Hi, Norman,

I drag a picture to a canvas and I want to save it to a destination
[/quote]
My question is more do you want to create a new picture from the one dragged in (a copy) & save that some where ?
Or just the location the picture came from so you can find it from that same location later ?

From the code you posted it looks like the second
And its a LOT Simpler than you’re trying to make it

Save the “NativePath” as a string (where ever it is you want to)

dim theFilesLocation as string = obj.FolderItem.NativePath
Thats it

Then to get it back you just do

       dim f as folderitem = GetFolderItem( theFilesLocation, FolderItem.PathTypeNative )

done !

Now you can use some other mechanisms and they may be more robust (like if the file is moved etc)
But this will work assuming the file doesn’t get moved etc

Trust me there’s only one Thomas :slight_smile:

Indeed there is ;-). The code you have given is useful for other things indeed, as as string cannnot be converted to a folderitem. Thanks for your help, Norman!