如何在 compose 桌面中获取 MacO 上的当前工作目录
我想获取当前的工作目录,以便调用一些命令。我从 jetpack compose 桌面库的演示复制了代码,但得到了错误的目录(“/”)。谁能告诉我出了什么问题吗?谢谢。
(jetpack compose 桌面库:https://github.com/JetBrains/compose-jb/blob/master/tutorials/Native_distributions_and_local_execution/README.md)
val userDirStr = File(System.getProperty("user.dir"))
if (userDirStr != null) {
println("Row, onGloballyPositioned, userDirStr = " + userDirStr)
outputText = "directory = " + userDirStr
}
I wanna get current working dir, in order to call some commands. I copied code from jetpack compose desktop lib's demo, but got wrong dir("/"). Could any one tell me what's the problem? thank you.
(jetpack compose desktop lib: https://github.com/JetBrains/compose-jb/blob/master/tutorials/Native_distributions_and_local_execution/README.md)
val userDirStr = File(System.getProperty("user.dir"))
if (userDirStr != null) {
println("Row, onGloballyPositioned, userDirStr = " + userDirStr)
outputText = "directory = " + userDirStr
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我构建了一个新的 Compose Crossplatform 项目,并将旧代码复制到其中。
然后“File(System.getProperty(“compose.application.resources.dir”))”就得到了正确的路径。
I build a new Compose Crossplatform project, and copy old code into it.
Then "File(System.getProperty("compose.application.resources.dir"))" just got the right path.