在Javascript中获取文件名的目录
问题描述:
如何获取文件目录?
例如,我传入一个字符串
For example, I pass in a string
C:\Program Files\nant\bin\nant.exe
我想要一个返回我的函数
I want a function that returns me
C:\Program Files\nant\bin
我更喜欢内置函数来完成工作,而不是手动拆分字符串和排除最后一个。
编辑:我在Windows上运行
答
我不知道这是否有任何内置功能,但它很容易获得路径。
I don't know if there is any built in functionality for this, but it's pretty straight forward to get the path.
path = path.substring(0,path.lastIndexOf("\\")+1);