解析标准目录之外的相对路径(applicationDirectory、desktopDirectory 等)
我需要导航到相对于我的 applicationDirectory 的文件,但正如文档中所述:
没有到达文件系统根或应用程序持久存储根的“..”引用传递该节点;它被忽略了。
但疯狂的是,如果我做了类似的事情,
File.applicationDirectory.resolvePath("/home/myHome/");
我就可以到达文件系统中的任何地方。
我的问题是: 是否有解决方法可以从我的 applicationDirectory 导航到像“../../my.cfg”这样的相对路径? (我需要读取由不同应用程序生成的配置文件)
I need to navigate to a file relative to my applicationDirectory, but as it says in the documentation:
No ".." reference that reaches the file system root or the application-persistent storage root passes that node; it is ignored.
But the crazy thing is that if I do something like
File.applicationDirectory.resolvePath("/home/myHome/");
I can get anywhere in the filesystem.
My question is:
is there a workaround to navigate from my applicationDirectory to a relative path like "../../my.cfg" ?? (I need to read a config file generated by a different application)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试访问根特权文件夹 - 则不能。
在其他情况下,请尝试执行下一个“home/blah/blah/blah/../../my.cfg”并再次研究http://help.adobe.com/en_US/AIR/1.5/jslr/flash/filesystem/File.html 以节省您的时间关于导航。
您还有其他几种方法:创建文件的链接或运行外部 bash/bat 脚本。
if you are trying to access root privileged folders - than you can not.
in other cases try do next "home/blah/blah/blah/../../my.cfg" and research once again http://help.adobe.com/en_US/AIR/1.5/jslr/flash/filesystem/File.html to save your time about navigation.
also you have another few ways: create a link to your file or run external bash/bat script.
我之前使用尤金的答案中提到的小技巧从绝对路径复制:
但是,这是一种更好的方法:
I was previously using the little hack mentioned in Eugene's answer to copy from an absolute path:
However, this is a much better way of doing it: