FolderItem Troubles (Accessing File)

Hi all,

I’m having an issue with some files/folderitems on Windows from files that were originally created on Mac.

As an example, I have a file with the following path:

X:\\archives\\december 2017\\MYMP3POOL (MAINSTREAM) - 12-21-17\\._Lil Jon 2018 New Years Eve Drops And Count Downs (Dj Hope) (44 Tools) (Clean and Dirty)

I can create a FolderItem pointing to this file with the code:

dim f as FolderItem f=GetFolderItem("X:\\archives\\december 2017\\MYMP3POOL (MAINSTREAM) - 12-21-17\\._Lil Jon 2018 New Years Eve Drops And Count Downs (Dj Hope) (44 Tools) (Clean and Dirty)", FolderItem.PathTypeNative)

I get a valid FolderItem, but if I check f.Exists it returns false, even though the file does indeed exist (it’s a MacOS metadata file and has a size of 239 bytes). Any operations I attempt on this file from Xojo code fail. I would like to delete it with f.Delete but nope! Error code 101, file not found.

I thought maybe there was a file attribute issue. I checked the attributes of the file for hidden/read-only, and it turns out the file has NO attributes whatsoever. But it doesn’t seem to matter as even if I set any file attributes (such as Archive) I still receive the error.

I can open the file in Notepad, copy/delete it in Windows Explorer, everything seems to be able to access it except the Xojo file operations.

I am running into this problem repeatedly and it’s always with these metadata files that came over to my Windows computer from a Mac.

Any ideas?

[code]dim f as folderitem
f = get folderitem("“X:\archives\december 2017\MYMP3POOL (MAINSTREAM) - 12-21-17”)

//does F exist?
if f.exists and f <> nil then
//if you reach here the folder is OK, but you would be better building it up step by step

dim thefile as folderitem
thefile = f.child("._Lil Jon 2018 New Years Eve Drops And Count Downs (Dj Hope) (44 Tools) (Clean and Dirty)")
i

//does thefile exist?
//is it nil?

//how many .child records does f have?

end if[/code]

I use code to delete Mac metadata files created by unzipping an archive. Works OK for me
But importantly , they do exist
I think you may just have the path or name wrong.
Try iterating through the children of the F folderitem, and delete them if the name begins with a .

As Jeff wrote above, creating a FolderItem from a Path is dangerous because each atom (directory on WIndows, folder on macOS) can be Nil.

Iterate from the path and check each atom is mandatory to avoid troubles, IMHO.

Dim f As FolderItem f = GetFolderItem("Z:\\scrap\\MYMP3POOL (MAINSTREAM) - 12-21-17\\._Lil Jon 2018 New Years Eve Drops And Count Downs (Dj Hope) (44 Tools) (Clean and Dirty)", FolderItem.PathTypeNative) If f.exists() Then system.DebugLog("EXISTS") End If

Odd, that works here on a mapped network drive, I assume that’s what it is in your example?

What is X mapped to? What format is the drive? What is hosting it?

Try calling this after your f.exists check to see if any errors are happening:

Declare Function GetLastError Lib "Kernel32" () As UInt32 Dim e As UInt32 e = GetLastError() system.DebugLog("error=" + str(e))