"Unsupported Format" creating a folder item?

I just had a bug report from one of my users, looking at the error log I found that this line:

f=new FolderItem(“Help”)

Raised an “Unsupported Format” exception.

I’m already trapping this error (as the error log showed), but I’m curious about what situations would cause this kind of exception?

When creating a New folderitem, you need to specity a path type. Try removing the New operator and then just call f.CreateAsDirectory.

f=New FolderItem("/home/shr/mytextdoc.txt",FolderItem.PathTypeShell) <-- 2nd parameter missing

I just fell victim to this oversight in a post made yesterday.

This code has worked for years, it’s getting the Help folder from the same directory as the app. I don’t know why it failed for this one user when it works for everyone else. I’m not creating a directory, just checking to see if it exists.

The Language Reference says:


The GetFolderItem function can be used to get a FolderItem for an item in the current directory. Simply pass it the name of the item. For example, the following returns a FolderItem for the directory “MyTemplates” in the current folder:
Dim f as FolderItem
f= GetFolderItem(“MyTemplates”)

If the document or directory does not exist, the Exists property of the FolderItem is False.

In the case of this one user, he got an UnsupportedFormat exception. It hasn’t happened to anyone else among thousands of users. I’m just trying to understand what might have caused the exception to be raised. Would adding FolderItem.PathTypeShell as a second parameter prevent getting the exception?

New Folderitem is not the same as GetFolderitem!

Right in your code, just use:

f=FolderItem("Help")

without the “New” operator.

I’ll give it a try, thanks!

[quote=119843:@Greg O’Lone]Right in your code, just use:

f=FolderItem("Help")

without the “New” operator.[/quote]

Won’t compile without “New”.

I’ll just put a try/catch around the existing code and call it a day. It’ll still work for the >9,999 people who use it, there’s just one who won’t have access to Help.

f= GetFolderItem(“Help”)