Folderitem error 105 - what am I doing wrong?

I have this code in a method:

[code]Dim fPDF As folderitem
fPDF = New FolderItem(CList, FolderItem.PathTypeNative)

If fPDF <> Nil And fPDF.Exists Then
PDFFile = WebFile.Open(fPDF)
PDFFile.ForceDownload = True
End If

If PDFFile <> Nil Then
MsgBox(“The PDF file is not available.”)
End If
I placed a breakpoint at if fPDF… to evaluate the variables. In the case at hand, CList is “S:\TEMP\redbook 2016-2017 eng.pdf” I never get to open the webfile, because fPDF generates an error 105. invalid filename.

If I put the CList string in File Explorer, I open the target file correctly, so I know that the string is good. I can’t figure out why I am getting this error 105. It is probably something really simple, but I just cant figure it out. I tried with underscores instead of spaces in the filename, same result.

Thanks in advance.

edit: 2017 R1.1 on Windows 10

You have spaces in the file path – I think you need to escape them. I do not remember, but it might be the caret symbol ^.

"S:\\TEMP\\redbook^ 2016-2017^ eng.pdf"

Eli, that may be right, but as I indicated, I had undercores in place of spaces before. Error 105 was happening regardless. I forgot to mention that this is on Windows 10.

As it turns out, adding CList = TRIM(CList) before fPDF = New FolderItem(CList, FolderItem.PathTypeNative) corrects the error.

I don’t quite understand why, since File Explorer opened the file just fine using the CList string. In any case, some null or non-printable character was apparently causing the error.

duh… CList is the output of a shell process. It has the end of line characters appended. Seems so obvious now…