# File FolderItem doesn't ??? exist

**URL:** <https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354>\
**Category:** General\
**Created:** [February 27, 2017, 3:10pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354 "2017-02-27T15:10:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 3:10pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/1 "2017-02-27T15:10:45Z")

</div>

I have a line of code that should be detecting a folder that exists,  
but doesn’t according to either the debugger on Windows 10 (debugger reports tsfb.Child(“PrefsFile”).exists = False) and does exist on my Mac (my program doesn’t crash).  
I upgraded from 2014 to 2016 and it was a problem in both versions. [code]If tsfb.Child(“PrefsFile”).Exists = False Then  
tsf = Nil  
Else  
tsf = tsfb.Child(“PrefsFile”)

```
			End If[/code]

```

Suggestions?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 27, 2017, 3:19pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/2 "2017-02-27T15:19:26Z")

</div>

Super tripple double check the path of the item in the debugger to the path of the item you believe it’s pointing to.

What’s the code that defines tsfb and tsf?  
(you should try useful variable names sometime)

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [February 27, 2017, 3:46pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/3 "2017-02-27T15:46:01Z")

</div>

may be you are missing second folderitem parameter

```auto
dim tsfb as Folderitem = GetFolderItem("/path/to/tsfb", FolderItem.PathTypeNative)
If tsfb <> Nil and tsfb.Exists Then
tsf = tsfb.Child("PrefsFile") 
If tsf <> Nil And tsf.Exists Then
 // do it
End If
End If
```

---

<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:** [February 27, 2017, 3:59pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/4 "2017-02-27T15:59:00Z")

</div>

> [@](#):
>
> on Windows 10 (debugger reports tsfb.Child(“PrefsFile”).exists = False) and does exist on my Mac (my program doesn’t crash).

1: get it working on one platform before you waste time on the other  
2: Its not a crash, its a nilobject exception. Your code should test for and trap this.  
3: I bet that somewhere in your code you are creating a file path that is relative to the application. The paths aren’t the same in the debugger between windows and mac.  
4: Dont use files located ‘next to the app’ (ie in the same folder) That definitely wont work when you try to deploy. Use Specialfolder.applicationdata children instead

5: (as Tim says) Super tripple double check the path of the item in the debugger to the path of the item you believe it’s pointing to. Because you almost certainly didnt.

> [@](#):
>
> I upgraded from 2014 to 2016 and it was a problem in both versions

Its your code, not the version of Xojo

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 27, 2017, 4:09pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/5 "2017-02-27T16:09:07Z")

</div>

> [@318176:@Arthur Gabhart](#):
>
> Suggestions?

Don’t ever use `GetFolderItem` unless you absolutely have to.

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 4:18pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/6 "2017-02-27T16:18:47Z")

</div>

> [@](#):
>
> 1: get it working on one platform before you waste time on the other

Sorry I wasn’t clear enough. My code does work on Mac currently, and used to work on my PC at some point in time. I’ve been working on this since 2005 and this segment for a few years back (2013 maybe). Again it worked. It’s okay if XOJO improves and I’m happy.

> [@](#):
>
> 2: Its not a crash, its a nilobject exception. Your code should test for and trap this.

Absolutely. I cheated and have a lot of trys to add.

> [@](#):
>
> 3: I bet that somewhere in your code you are creating a file path that is relative to the application. The paths aren’t the same in the debugger between windows and mac.

I’m not sure about relative as in object language concept. This might be the 2nd path the program uses. The first was identifying the path leading to this folder.

> [@](#):
>
> 4: Dont use files located ‘next to the app’ (ie in the same folder) That definitely wont work when you try to deploy. Use Specialfolder.applicationdata children instead

Somehow I got the next to the app right. It’s under/below the app in a folder called data. This is actually the first path.  
I also should spend time moving stuff over to SpecialFolder. Later.

> [@](#):
>
> 5: (as Tim says) Super tripple double check the path of the item in the debugger to the path of the item you believe it’s pointing to. Because you almost certainly didnt.

I’m not sure how I can check it deeper. I know the enclosing folder exists and the file does have the same name as in Windows Explorer.

For Tim Parnell

```auto
tsfb = GetFolderItem(ts, 3)//.Child("PrefsFile")
```

What other code can I use?  
Also Tim’s name isn’t highlighted like in Facebook. How do I identify him.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 27, 2017, 4:24pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/7 "2017-02-27T16:24:12Z")

</div>

> [@318185:@Arthur Gabhart](#):
>
> I’m not sure about relative as in object language concept. This might be the 2nd path the program uses. The first was identifying the path leading to this folder.

No we’re talking about the path relativity, because that’s a huge part of `GetFolderItem`.

> [@318185:@Arthur Gabhart](#):
>
> Somehow I got the next to the app right. It’s under/below the app in a folder called data. This is actually the first path.

I doubt that, you’re having errors.

> [@318185:@Arthur Gabhart](#):
>
> I also should spend time moving stuff over to SpecialFolder. Later.

This is a major part of your problem. Make this your priority.

[quote=318185:@Arthur Gabhart]  
I’m not sure how I can check it deeper. I know the enclosing folder exists and the file does have the same name as in Windows Explorer.[/quote]  
Check the Native Path value versus the full path to the item you’re trying to locate.

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [February 27, 2017, 4:31pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/8 "2017-02-27T16:31:11Z")

</div>

@Arthur Gabhart  
You asked the same 4 weeks ago and got many tips  
(SpecialFolder.ApplicationData)

[https://forum.xojo.com/38823-windows-getfolderitem-nilobjectexception-error](https://forum.xojo.com/38823-windows-getfolderitem-nilobjectexception-error)

---

<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:** [February 27, 2017, 5:00pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/9 "2017-02-27T17:00:47Z")

</div>

[quote]Somehow I got the next to the app right. It’s under/below the app in a folder called data. This is actually the first path.  
I also should spend time moving stuff over to SpecialFolder. Later.[/quote]

Thats not getting it right.  
Its the whole reason why ‘it works’ on one platform and not on the other.  
data folder is not where you think it is.

You start somewhere by using GetFolderitem("") I suspect  
Then you just save a file without a path, or as a child of that .  
Thats ‘next to the app’  
Thats bad news, don’t do that, for all the reasons in this post and your others. Change it now.

When you run in debug mode, paths are different on PC and Mac.  
The file isnt where you think it is, and using the debugger you can look at the whole path of the file… you will find there is an extra folder name in there which you dont expect

That doesn’t happen if your files are in Application Support folder.  
Change it now.

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 5:19pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/10 "2017-02-27T17:19:02Z")

</div>

[link text](https://xojo.io/e1f4f6e47e40)

[quote=318186:@Tim Parnell]No we’re talking about the path relativity, because that’s a huge part of `GetFolderItem`.

I doubt that, you’re having errors.

This is a major part of your problem. Make this your priority.

Check the Native Path value versus the full path to the item you’re trying to locate.[/quote]  
The above image is the path from Windows Explorer. It matches the path. Also when I check paths in the debugger they are the same.

What else is good at identifying a path? GetTrueFolderItem?

Yes I did use the “” to get my first path. And that’s (I think) what the path for the PrefsFile is. It is according to the debugger. So no extra folder like debugger. The “iniPaths.ini” has a getfolderitem and it has the same path and paths (native, etc)

` rf = GetFolderItem("")
		IniPath = rf.Child("Data").Child("iniPaths.ini")
		`  
Is there a good explanation of setting up Special Folders? I am not sure what I need to or can include.

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [February 27, 2017, 5:21pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/11 "2017-02-27T17:21:30Z")

</div>

> [@318202:@Arthur Gabhart](#):
>
> Is there a good explanation of setting up Special Folders? I am not sure what I need to or can include.

[https://forum.xojo.com/conversation/post/316705](https://forum.xojo.com/conversation/post/316705)

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 27, 2017, 5:26pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/12 "2017-02-27T17:26:09Z")

</div>

> [@318202:@Arthur Gabhart](#):
>
> What else is good at identifying a path? GetTrueFolderItem?

When it comes to FolderItem if you don’t start with SpecialFolder or a Open/Save dialog, you’re asking for trouble.  
If you’re saving paths from user input, use [http://documentation.xojo.com/index.php/FolderItem.GetSaveInfo](http://documentation.xojo.com/index.php/FolderItem.GetSaveInfo) to store it.

> [@318202:@Arthur Gabhart](#):
>
> Is there a good explanation of setting up Special Folders? I am not sure what I need to or can include.

[http://documentation.xojo.com/index.php/SpecialFolder](http://documentation.xojo.com/index.php/SpecialFolder) - it’s just a bunch of pre-existing locations to work with.

I would recommend using my module over what Axel linked. The less you have to maintain, the easier your job will be.

> **[GitHub - devtimi/TPSF: Module for accessing build step folders with the old...](https://github.com/devtimi/TPSF)**
>
> Module for accessing build step folders with the old framework. - GitHub - devtimi/TPSF: Module for accessing build step folders with the old framework.

But the choice is yours.

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 5:31pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/13 "2017-02-27T17:31:46Z")

</div>

> [@318205:@Axel Schneider](#):
>
> [https://forum.xojo.com/conversation/post/316705](https://forum.xojo.com/conversation/post/316705)

Yes. I got that, but I am looking for information on other things, like what actually goes in a preferences file.  
Another problem is does it go in a folder of my creation or Windows/Apple?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 27, 2017, 5:33pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/14 "2017-02-27T17:33:31Z")

</div>

> [@318209:@Arthur Gabhart](#):
>
> Another problem is does it go in a folder of my creation or Windows/Apple?

My module takes care of that automatically, `TPSF.AppSupport` returns a FolderItem child of the application data folder that is set up properly for Mac / Windows. All you have to do is check if it exists and create it if not.

---

<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:** [February 27, 2017, 5:34pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/15 "2017-02-27T17:34:27Z")

</div>

From your screenshot:

mainfolder = Specialfolder.Documents.child(“Basic Programming”)  
reviewcardsfolder = mainfolder.child(“ReviewCards”)  
Datafolder = reviewcardsfolder.child(“Data”)  
Databasefolder = Datafolder.child(“Base”)  
prefsfile = Databasefolder.child(“Prefsfile”)

> [@](#):
>
> what actually goes in a preferences file

if you dont know, you dont need one.  
Color selections, last window sizes, language preference, question difficulty… anything that you want the program to remember when you come back to it as a user tomorrow.

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 5:38pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/16 "2017-02-27T17:38:54Z")

</div>

[quote=318206:@Tim Parnell]When it comes to FolderItem if you don’t start with SpecialFolder or a Open/Save dialog, you’re asking for trouble.  
If you’re saving paths from user input, use [http://documentation.xojo.com/index.php/FolderItem.GetSaveInfo](http://documentation.xojo.com/index.php/FolderItem.GetSaveInfo) to store it.  
.[/quote]  
I created the super folder (Base) with my program and a dialog. I can’t locate the actual line I used but it’s there.  
The program does use GetSaveInfo. I just confirmed.

Thanks for the location to your program Tim.

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 6:06pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/17 "2017-02-27T18:06:25Z")

</div>

Thanks @[quote=318211:@Jeff Tullin]From your screenshot:  
It will help soon.

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [February 27, 2017, 6:09pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/18 "2017-02-27T18:09:50Z")

</div>

[quote=251266:@Norman Palardy]RE : GetFolderItem("", FolderItem.PathTypeNative)  
“” is a relative path which you cannot use with PathTypeNative[/quote]  
How do I convert a relative to native path?

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [February 27, 2017, 6:38pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/19 "2017-02-27T18:38:28Z")

</div>

@Tim Parnell

I added your TPSF to this Demo for getting SpecialFolder Paths in Linux  
(There are problems when the Folder Names are translated)

[https://www.dropbox.com/s/4ksj83z3n9xfhqu/TPSF\_2.zip?dl=1](https://www.dropbox.com/s/4ksj83z3n9xfhqu/TPSF_2.zip?dl=1)

TPSF Button should work on all OS

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 27, 2017, 6:48pm UTC](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354/20 "2017-02-27T18:48:25Z")

</div>

Thanks, I’ll try to get the changes merged in soon 🙂

Edit: Oh, I thought you added a bunch of linux paths. I know there’s no linux support on the module yet.

[Next page](https://forum.xojo.com/t/file-folderitem-doesnt-exist/36354.md?page=2)
