Windows GetFolderItem NilObjectException Error

I am using 2014 R2 on a Mac and Pc (both current OSes). I get this NilObjectException error on my pc but not my mac.
The line of code throwing the error is:

If tsfb.Child("PrefsFile").Exists = False Then

The preceeding lines are:

Dim ts, TitPthArray(), tsPath, str As String Dim tsf, tsfb As FolderItem

tsPath = TitPthArray(i).NthField(Chr(9), 2) ts = DecodeBase64(tsPath, Encodings.UTF8) tsfb = GetFolderItem(ts, 3)//.Child("PrefsFile") If tsfb.Child("PrefsFile").Exists = False Then tsf = Nil
Questions:
Is there something wrong with my code?
Is this an error that got fixed?
I tried doing a search in releases and couldn’t find something relevant.

Also, I thought about getting a new release, but had to pay full price. Any ideas about getting a discount.

It would greatly help if instead of

tsPath = TitPthArray(i).NthField(Chr(9), 2) ts = DecodeBase64(tsPath, Encodings.UTF8) tsfb = GetFolderItem(ts, 3)//.Child("PrefsFile")

Please post the resulting path.

Chances are your path is ill formed on PC.

Usually, preference files should be placed in a subfolder of SpecialFolder.ApplicationData named likes “com.greatsoftware.mygreatapp” (put the name of your company and app there). So it works perfectly cross platform.

I would write

tsPath = TitPthArray(i).NthField(Chr(9), 2)
ts = DecodeBase64(tsPath, Encodings.UTF8)
tsfb = GetFolderItem(ts, 3)//.Child("PrefsFile")
If tsfb <> nil and tsfb.exists then
tsf = tsfb.Child("PrefsFile")
if tsf <> nil and tsf.exists then
// code here
else
 //code  here  //tsf = Nil
end if
end if
If tsfb.Child("PrefsFile").Exists = False Then

Either the tsfb reference is Nil (meaning GetFolderItem returned Nil, possibly because the path is invalid), or it doesn’t refer to an existing directory (causing .Child to return Nil).

You can use the debugger to examine the value of tsfb at the moment the exception is raised, or decompose the errant line into two or more lines to see which statement is raising the exception.

You’re correct, Michel, since the string ‘ts’ is good only for that folder above and above.
I’ve got problems with a line above that should be returning a folderitem and I’ve got nothing.

[code] ts = App.StrpEncode(IniPath, “iniPaths.ini”, False)

If ts <> “” Then TitPthArray() = Split(ts, EndOfLine)[/code]
App.StrpEncode returns the text of a file and stipping the BOM, the next line should be turning this text into 3 cells of an array but it’s only 2.

[quote]0
Base APHRcwEAAgAAAAAEQmFzZQEAAAAASUM6XFVzZXJzXEFydGh1ciBHYWJoYXJ0XERvY3VtZW50c1xCYXNpYyBQcm9ncmFtbWluZ1xSZXZpZXdDYXJkc1xEYXRhXEJhc2UDAAAAAAEABAAAAAABAAAAAAAAAA==
[/quote]
The 3rd line should result after DecodeBase64 into the correct path, but my endofline after ‘Base’ is missing.

Is there a GOOD tutorial on SpecialFolder.ApplicationData. I have a lot of data and it’s very convoluted. After not looking at this for a couple of years, I’m very intimidated.

for example
create a property
pref_file as folderitem

then use ( in App.Open)

dim appsupportfolder as FolderItem = SpecialFolder.ApplicationData.Child _ ("myAppName") if not appsupportfolder.exists then f.CreateAsFolder pref_file = appsupportfolder.Child("PrefsFile")

Thanks for the simple explanation. I’ll put that into my list of “to do”.

For the String ts in the Binary view, the character that is my endofline is a ‘.’
I’d like to identify that.
Is there a good program that will identify the values of a character in various formats (UTF)?
I did a search on Windows store for ASCII and came up with nil for programs.
Suggestions?

I have made a mistake, should be

dim appsupportfolder as FolderItem = SpecialFolder.ApplicationData.Child _ ("myAppName") if not appsupportfolder.exists then appsupportfolder.CreateAsFolder pref_file = appsupportfolder.Child("PrefsFile")

SpecialFolder.ApplicationData to save Prefs files ?

What SpecialFolder.Preferences is for ?

Nothing anymore. Apple said not to write your own preferences, and to use NSUserDefaults, and so we all changed. And in turn, it ended up affecting how we write apps for Windows too.