I need to open a file that resides in the AppData\Local folder. Since there’s not a SpecialFolder property for this folder (most are for AppData\Roaming), I tried starting with SpecialFolder.UserHome and drilling down from there. I keep getting a NilObjectException when referencing anything in or below the Local folder (e.g. C:\Users\username\AppData\Local\somefile). Yet, I can use GetFolderItem with a hardcoded path with or without Child items and it all works fine. In all these cases, the file and/or folder does indeed exist. Here’s some examples:
[code]Dim f As FolderItem
// the following causes a NilObjectException
f = SpecialFolder.UserHome.Child(“AppData”).Child(“Local”).Child(“Star”).Child(“star.ini”) '<= NilObjectException
// and so does this
f = SpecialFolder.UserHome.Child(“AppData”).Child(“Local”).Child(“somefile”) '<= NilObjectException
// this works fine
f = SpecialFolder.UserHome.Child(“AppData”).Child(“Local”)
// but if you then try to build from there, it doesn’t:
f = f.Child(“somefile”) '<= NilObjectException
// these are the only ways I can get it to work
f = GetFolderItem(“C:\Users\Jay\AppData\Local\Star\Star.ini”, FolderItem.PathTypeAbsolute)
// or
f = GetFolderItem(“C:\Users\Jay”, FolderItem.PathTypeAbsolute)
f = f.Child(“AppData”).Child(“Local”).Child(“Star”).Child(“star.ini”)
[/code]
What’s also confusing is that the docs for Child state that if the file or folder doesn’t exist, then f will be nil. But it doesn’t get far enough to test that - it crashes with a NilObjectException.