Path.GetFileNameWithoutExtension 获取无扩展名的文件名

static function GetFileNameWithoutExtension (path : string) : string

Description描述

Returns the file base component of the specified path string without the extension.

返回指定路径字符串组件的基本文件名,不带有扩展名。简单来说就是返回一个没有扩展名的文件名。

The return value consists of the string returned by GetFileName(), minus the extension separator character and extension.

返回值包括由GetFileName()返回的字符串,去掉扩展名分隔符和扩展名。

using System.IO;
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Start() {
		Debug.Log(Path.GetFileNameWithoutExtension("/Some/File/At/foo.extension"));
	}
}
//Remember to import IO to make Path work.
//记得导入IO,使Path工作
import System.IO;

function Start () {
	//This will print "foo".
	//这会打印"foo"
	Debug.Log(Path.GetFileNameWithoutExtension("/Some/File/At/foo.extension"));
}
Page last updated: 2011-3-11