我需要获取iOS应用程序的“库”专用应用程序文件夹的完整路径。
在斯威夫特,我会用
let dir = try! FileManager.default.url(for: .libraryDirectory, in: .userDomainMask, appropriateFor: nil, create: true);
然后
let fileUrl = dir.appendingPathComponent(fileName).appendingPathExtension("json");
我在StackOverflow上看到这种路径
file:///var/mobile/Containers/Data/Application/strangenumberslike...EF22-EB33-4B65-9772-67ED7870E3E9/Library/
问题确实涉及“文档”(因此示例可能是错误的)。
我需要的是在一个不能直接检索的跨平台环境中以这种形式获取库文件夹,但它具有文档绝对路径。
我认为这只是子字符串(JAVA)的问题,也就是说文件夹有相同的“根”。
也许 吧
String root=documentPath.substring(0,documentPath.indexOf("Document"));
String libraryPath=root+"/Library";
这可能吗?