New Folderitem API

I’m having trouble with folderitem in the new API…

Var d as New folderitem(“D:\2014\07192014\50_3ECD749C.PDF”) works just fine…

but when I have a variable pdf_file that contains D:\2014\07192014\50_3ECD749C.PDF, then

Var d as New folderitem(pdf_filename) gives me UnsupportedFormatException

Any help would be greatly appreciated…

In one sentence you use the variable name “pdf_file” and in the other you use “pdf_filename”. Is this just a typo and you use the right variable in the code?

Sorry, that’s a typo…

If you put a breakpoint on that line, have you verified the contents of pdf_filename is in fact what you think it is?

I tend to prefer not using delimiters like “\” but build my way out to the final path component using .Child() references because it is more multi-platform friendly.

Edit: Escaped the backslash character so the shows up in the reply.

Hey Douglas, yes I did confirm that…Do you have an example of how you build out the final path??

@Kenneth_Lossman

This should help:
https://docs.xojo.com/FolderItem.Child

Also:
https://docs.xojo.com/SpecialFolder

there are more parameters in the constructor

Shell Path

If you pass a Shell path, it must be an absolute path. If not, an UnsupportedFormatException will result

try adding FolderItem.pathModes.Native to the new statement

I added Folderitem.pathModes.Native and I still get the same error…The confusing issue is this has worked in the past even up to a few weeks ago…

Well I dunno. I do:

Var  start as String, dirh as FolderItem

dirh = new FolderItem (start, FolderItem.PathModes.Native)

all over my app with no issues.

What is pdf_file defined as, a string or a folderitem?

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.