Path.GetFileName Manual     Reference     Scripting  
Scripting > Runtime Classes > Path
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.

JavaScript
//Remember to import IO to make Path work.
import System.IO;

function Start () {
//This will print "foo.extension".
Debug.Log(Path.GetFileName("/Some/File/At/foo.extension"));
}

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

public class example : MonoBehaviour {
void Start() {
Debug.Log(Path.GetFileName("/Some/File/At/foo.extension"));
}
}

import System.IO
import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Start():
Debug.Log(Path.GetFileName('/Some/File/At/foo.extension'))