如何在macOS上以编程方式将文件和文件夹移至“废纸rash"? [英] How to move files and folders to Trash programmatically on macOS?
本文介绍了如何在macOS上以编程方式将文件和文件夹移至“废纸rash"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在该主题上我能找到的只是对FSMoveObjectToTrashSync
函数的提及,该函数现在为不推荐使用,并且没有其他替代品.
All I can find on this topic is mentions of FSMoveObjectToTrashSync
function, which is now deprecated and no alternative is listed for it.
如何用C或Objective-C代码实现?
How to do it from C or Objective-C code?
推荐答案
使用NSFileManager:
Use NSFileManager:
https://developer.apple.com/documentation/foundation/nsfilemanager
- trashItemAtURL:resultingItemURL:error: 将物品移到垃圾箱.
- trashItemAtURL:resultingItemURL:error: Moves an item to the trash.
这篇关于如何在macOS上以编程方式将文件和文件夹移至“废纸rash"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文