Path.GetFileName 获取文件名
static function GetFileName (path : string) : string
Description描述
Returns the file name, including the extension if any, of the specified path string.
返回指定路径字符串的文件名,包含扩展名。
The return value consists of the characters after the last directory character in path. If the last character of path is a directory separator character, returns an empty string.
返回值在路径最后一个目录分隔符之后组成。如果最后一个路径字符是一个路径分隔符,返回一个空字符串。
using System.IO;
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Start() {
Debug.Log(Path.GetFileName("/Some/File/At/foo.extension"));
}
}
//Remember to import IO to make Path work.
//记得导入IO,才能是路径正常工作
import System.IO;
function Start () {
//This will print "foo.extension".
//这将打印foo.extension
Debug.Log(Path.GetFileName("/Some/File/At/foo.extension"));
}
最后修改:2011年3月11日 Friday 11:51