简体   繁体   中英

Javascript file's parent folder

every time I need to get the name of a folder a file targetFile is located in, I always have to write out this tedious:

var parentFolder = targetFile.path.toString().substring(targetFile.path.toString().lastIndexOf('/'), targetFile.path.toString().length)

am I missing something horribly easy to get this?

Is this something that you need to do dynamically? Why not just store it as a constant?

Alternatively, just create a function that executes the code you pasted...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM