Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Path.GetFileName(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 ExampleClass : MonoBehaviour { void Start() { Debug.Log(Path.GetFileName("/Some/File/At/foo.extension")); } }