SpecialFolder.Trash crashes

The below code produces crashes. It works fine with 10.14 or earlier.
I need the correct Trash path of all volumes. (btw for macOS 10.15 this is called Bin).

for x as integer = 1 to VolumeCount msgbox SpecialFolder.Trash(Volume(x-1)).NativePath next

Is this a known issue?

Forgotten to add:
It should return /Users/UserName/.Bin (and not /Users/UserName/.Trash) in macOS 10.15

<https://xojo.com/issue/57870>

Not a bug. You code doesn’t crash - it just has a NOE. Volume(0) doesn’t have a trash because it’s read-only.

It is a bug because:

  • It cycles thru the volumes (even when you use try catch)
  • It works fine with macOS 10.14 and earlier.

Did you try?

for x as integer = 1 to VolumeCount Try msgbox SpecialFolder.Trash(Volume(x-1)).NativePath Catch End try next

I tried your code. There is no crash and you need to catch the NOE. And some things changed with Catalina. So Volume(0) doesn’t have a trash anymore and you need to code around it.

Could this be related to the fact that macOS 10.15 now has a “read only” System Volume (which most likely doesn’t have a Bin/Trash)…?
I’m sure you have debugged this: Which Volume does crash the app with the code above? Is it some catchable exception (even if another than NilObjectException)?
If it’s indeed the new read-only System Volume, you might just want to exclude that one for now as a workaround…?

[quote=458082:@Christoph De Vocht]The below code produces crashes. It works fine with 10.14 or earlier.
I need the correct Trash path of all volumes. (btw for macOS 10.15 this is called Bin).

for x as integer = 1 to VolumeCount msgbox SpecialFolder.Trash(Volume(x-1)).NativePath next

Is this a known issue?[/quote]
I think you have (wrongly) assumed that every volume will have a trash folder. In macOS 10.15 the system partition is read-only so I imagine it won’t have one. The same might also be true for disk images / CD & DVD volumes.
You should really be checking that SpecialFolder.Trash(Volume(x-1)) is not Nil before trying to access any of its properties.

The problem is that it returns nil for every available volume. At least here on my clean install macOS 10.15

Basically I need the correct path for the Bin (formally Trash) that’s available on the desktop.