A quick test of GetTrueFolderItem shows that it doesn’t work with long file names/paths, neither does folderitem but xojo.io.folderitem does. Maybe @William Yu can shed some light on that, and confirm if its a bug or not?
If you just want to check if a file exists without creating loads of xojo.io.folderitem’s then you can use the following, note the \\?\ at the start of the path. This code will not follow symbolic links.
[code]Dim path As String = “\\?\C:\Users\Julian\Desktop\012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.txt”
Declare Function CreateFileW Lib “Kernel32.dll” Alias “CreateFileW” ( _
lpFileName As WString, _
dwDesiredAccess As UInt32, _
dwShareMode As UInt32, _
lpSecurityAttributes As Ptr, _
dwCreationDisposition As UInt32, _
dwFlagsAndAttributes As UInt32, _
hTemplateFile As Ptr _
) As Integer
Const FILE_FLAG_OPEN_REPARSE_POINT = &h00200000
Const FILE_READ_ATTRIBUTES = &h80
Const FILE_SHARE_READ = &h00000001
Const OPEN_EXISTING = 3
Const FILE_FLAG_BACKUP_SEMANTICS = &h02000000
Dim hFile As Integer
hFile = CreateFileW(path, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, Nil, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS Or FILE_FLAG_OPEN_REPARSE_POINT, Nil)
Dim fileExists As Boolean = False
If hFile <> -1 Then fileExists = True
Declare Function CloseHandle Lib “Kernel32.dll” Alias “CloseHandle” ( _
hObject As Integer _
) As Int32
Call CloseHandle(hFile)
system.DebugLog(“exists=” + str(fileExists))
[/code]