如何获取当前文件夹的名称,而不是文件夹的目录 [英] How to get the name of the current folder, not the dir to the folder
问题描述
我知道如何获取目录到文件夹,但我想得到的名称。
I know how to get the dir to the folder, but I'd like to get the name.
感谢您的帮助。
推荐答案
方法@Matt Shooks建议直接使用列表函数,而不是转换为数组(因为你只需要引用一次)。
A slightly more efficient method for doing what @Matt Shooks suggests would be to use list functions directly, rather than to convert to an array (since you only need to reference it once).
fullpath = getDirectoryFromPath(getCurrentTemplatePath())
Windows,并且您的全路径看起来像c:\inetpub\site\dir,您可以使用这个:
assuming that you are on Windows, and your fullpath looks something like c:\inetpub\site\dir, you can use this:
thisFolder = listlast(fullpath, "\/")
记住所有列表函数都可以使用分隔符可选),因此您可以将任何此类定义的字符串视为列表,而不仅仅是默认的逗号分隔列表。
Remember that all list functions can take a delimiter (optionally) so you can treat any string delimited like this as a list, not just the default comma-delimited lists.
这篇关于如何获取当前文件夹的名称,而不是文件夹的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!