# GetFolderItem API1 to API 2 conversion Syntax Error

**URL:** <https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844>\
**Category:** General\
**Created:** [September 3, 2026, 1:19pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844 "2026-09-03T13:19:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 3, 2026, 1:19pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/1 "2026-09-03T13:19:44Z")

</div>

Hello,

I wanted to start the conversion to the new format

My old line is : f=GetFolderItem(“Templates”).Child(“My Template”)

So I found in Documentation this new format but I always get syntax error. What’s wrong with it?

```auto
f = New FolderItem("Templates", FolderItem.PathModes.Native).Child("My Template")

```

Sometimes I got “New” as Deprecated. Thank you alot

---

<div class="post-metadata">

**Author:** ![kevin\_g](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kevin\_g](https://forum.xojo.com/u/kevin_g)\
**Post date:** [September 3, 2026, 1:46pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/2 "2026-09-03T13:46:14Z")

</div>

My guess is that you will to do this:

```auto
f = New FolderItem("Templates", FolderItem.PathModes.Native)
f = f.Child("My Template")

```

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 3, 2026, 1:50pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/3 "2026-09-03T13:50:43Z")

</div>

thank you. but i took the example exactly from the documentation. It should work also on a single line. I have a 500to1000 of this only in 1 application, transforming this on more than a line is a lot of work and less readable.

However I can’t find out to let it work like the examples in the documentation

and even with your example I get “New” as Deprecated warning message

---

<div class="post-metadata">

**Author:** ![kevin\_g](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kevin\_g](https://forum.xojo.com/u/kevin_g)\
**Post date:** [September 3, 2026, 2:12pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/4 "2026-09-03T14:12:30Z")

</div>

I had a quick look at the documentation and I could not see any examples similar to what you are trying to do.

As far as I am aware you can’t chain function calls when creating a new class instance but someone else might be able to comment on that.

You could put the code that creates a new FolderItem into a function as you would then be able to chain the Child call like you do with GetFolderItem.

Not sure why you are getting a deprecated warning for New as I have not seen that.

---

<div class="post-metadata">

**Author:** ![Michael\_Hußmann](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_hu%C3%9Fmann/32/438_2.png) [@Michael\_Hußmann](https://forum.xojo.com/u/Michael_Hu%C3%9Fmann)\
**Post date:** [September 3, 2026, 2:27pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/5 "2026-09-03T14:27:59Z")

</div>

> [@Giulio\_Straccia](#):
>
> but i took the example exactly from the documentation.

Are you sure? The syntax given for New doesn’t include calls like in your example. First you create the new object, then you call one of its methods – it’s always two steps.

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [September 3, 2026, 2:47pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/6 "2026-09-03T14:47:42Z")

</div>

Chaining FolderItem calls is an issue anyway. If it is a bad path or the FolderItem fails for some reason then you will trigger a NilObjectException.

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 3, 2026, 5:02pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/7 "2026-09-03T17:02:01Z")

</div>

Thank you for the suggestions , I know when and how to handle errors and sincerely also in other languages it’s very usual to write it on one single row. Split this single row in more than one is very unprofessional in a very big project

I still believe there must be a solution or something wrong in the code.

Documentation is here: [https://documentation.xojo.com/topics/file\_management/accessing\_the\_file\_system\_via\_the\_folderitem\_class.html](https://documentation.xojo.com/topics/file_management/accessing_the_file_system_via_the_folderitem_class.html)

 ![Screenshot 2026-09-03 185930](https://forum.xojo.com/uploads/default/original/3X/3/8/380df48c8b5326f255b894a5a48c78b2695d481e.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Hußmann](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_hu%C3%9Fmann/32/438_2.png) [@Michael\_Hußmann](https://forum.xojo.com/u/Michael_Hu%C3%9Fmann)\
**Post date:** [September 4, 2026, 12:01am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/8 "2026-09-04T00:01:18Z")

</div>

> [@Giulio\_Straccia](#):
>
> Documentation is here

The documentation appears to be in error here. New cannot be used like that and the compiler will complain about a syntax error if you try. You can’t very well argue with the compiler.

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 4, 2026, 5:27am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/9 "2026-09-04T05:27:58Z")

</div>

Hi Michael, I’m on your side.

But if you don’t use “New” compiler sends back error: “This method requires fewer parameters than were passed.”

---

<div class="post-metadata">

**Author:** ![Michael\_Hußmann](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_hu%C3%9Fmann/32/438_2.png) [@Michael\_Hußmann](https://forum.xojo.com/u/Michael_Hu%C3%9Fmann)\
**Post date:** [September 4, 2026, 9:42am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/10 "2026-09-04T09:42:02Z")

</div>

> [@Giulio\_Straccia](#):
>
> But if you don’t use “New” compiler sends back error: “This method requires fewer parameters than were passed.”

Of course, as you need to create a new FolderItem, and without New no constructor gets called and you cannot pass any parameters. It’s just that New cannot be used in the way that this example in the documentation suggests. The syntax of New ([New — Xojo documentation](https://documentation.xojo.com/api/language/new.html)) doesn’t support method calls, except implicitly by calling a constructor.

Just write the code in two lines and be done with it.

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [September 4, 2026, 9:49am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/11 "2026-09-04T09:49:39Z")

</div>

> [@kevin\_g](#):
>
> ```auto
> f = New FolderItem("Templates", FolderItem.PathModes.Native)
> f = f.Child("My Template")
> 
> ```

I think the documentation is wrong here. I don’t use API2, but to me it seems that there are brackets missing.

(If templates is missing, then you will get an error at run time, no matter what- you can’t get a child of a nil)

Does this work?

`f = (New FolderItem("Templates", FolderItem.PathModes.Native)).Child("My Template")`

This line:

`(New FolderItem("Templates", FolderItem.PathModes.Native))`

creates the folderitem parent, and you can have a child of that.

> I have a 500to1000 of this only in 1 application

Yikes.

Would it not make more sense to have a global variable **Folder\_Templates** initialised at startup?

Then all these calls would simply become

`f = ` **`Folder_Templates`** `.Child("My Template")`

If **`Folder_templates`** had been validated already, this line _should_ never error.

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 4, 2026, 10:14am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/12 "2026-09-04T10:14:23Z")

</div>

Thank you Jeff.

I already tried, but tried again just to be sure 🙂 but…

f = (New FolderItem(“Templates”, FolderItem.PathModes.Native)).Child(“My Template”)

is not working. it was the first thing I tried thinking behaviour would be like in other languages prioritizing () but not ☹

Probably I’ve to stick with your proposal or leave behind some API2 calls maybe Geoff is reading ?

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [September 4, 2026, 10:48am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/13 "2026-09-04T10:48:15Z")

</div>

The API 1 code using GetFolderItem works. Why not leave it as-is?

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 4, 2026, 11:16am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/14 "2026-09-04T11:16:04Z")

</div>

Hello Julia, I found out that deprecated methods API1 are not treated in the same way as API2. They don’t share always the same code and behavior could be little different. I think they left the code unchanged for compatibility issues and API2 gets internal improvements.

---

<div class="post-metadata">

**Author:** ![Michael\_Hußmann](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_hu%C3%9Fmann/32/438_2.png) [@Michael\_Hußmann](https://forum.xojo.com/u/Michael_Hu%C3%9Fmann)\
**Post date:** [September 4, 2026, 11:25am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/15 "2026-09-04T11:25:05Z")

</div>

> [@Giulio\_Straccia](#):
>
> Probably I’ve to stick with your proposal

I’d second Jeff’s proposal to initialise a Folder\_templates property at startup. In fact that’s exactly what I have done in one app where the same folder gets accessed at multiple points in my code.

---

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [September 4, 2026, 4:26pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/16 "2026-09-04T16:26:31Z")

</div>

I would just create a helper function:

```xojo
Function CreateFolderItem(Path) As FolderItem
  Return New FolderItem(Path, FolderItem.PathTypes.Native)
End Function

```

Use that in place of GetFolderItem and call it a day. Yes, there are better ways to handle this, but for the level of usage here, it’s at least a decent middle ground.

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 5, 2026, 8:57am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/17 "2026-09-05T08:57:22Z")

</div>

Thank you Thom,I just corrected some syntax. For sure the fastest way to replace GetFolderItem. Following is the corrected code:

Function CreateFolderItem(Path as String) As FolderItem  
Return New FolderItem(Path, FolderItem.PathModes.Native)  
End Function

---

<div class="post-metadata">

**Author:** ![RudolfJ](https://forum.xojo.com/user_avatar/forum.xojo.com/rudolfj/32/644_2.png) [@RudolfJ](https://forum.xojo.com/u/RudolfJ)\
**Post date:** [September 5, 2026, 9:33am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/18 "2026-09-05T09:33:30Z")

</div>

Hello  
missing  
f.CreateFolder ??

---

<div class="post-metadata">

**Author:** ![RudolfJ](https://forum.xojo.com/user_avatar/forum.xojo.com/rudolfj/32/644_2.png) [@RudolfJ](https://forum.xojo.com/u/RudolfJ)\
**Post date:** [September 5, 2026, 9:36am UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/19 "2026-09-05T09:36:09Z")

</div>

my test example  
[test-output-Input-Text2.xojo\_binary\_project.zip](https://forum.xojo.com/uploads/short-url/iitb8eTr9OUNCV1MYtU1viRX1uv.zip) (9.9 KB)

---

<div class="post-metadata">

**Author:** ![Giulio\_Straccia](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@Giulio\_Straccia](https://forum.xojo.com/u/Giulio_Straccia)\
**Post date:** [September 5, 2026, 5:30pm UTC](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844/20 "2026-09-05T17:30:02Z")

</div>

Hallo Rudolf,

just checked your example. Your way you always create a folder even if not requested and so you don’t have any control of it. Final solution is exactly is best solution to fix the Xojo-bug you can’t concatenate .Child(..)

PS: Du Alter, hab schon lange nicht mehr REM gesehen 🙂 das erinnert mich an alte Zeiten 🙂 Gruss

[Next page](https://forum.xojo.com/t/getfolderitem-api1-to-api-2-conversion-syntax-error/88844.md?page=2)
