---
title: removingLastComponent()
framework: system
role: symbol
role_heading: Instance Method
path: system/filepath/removinglastcomponent()
---

# removingLastComponent()

Creates a new path with everything up to but not including lastComponent.

## Declaration

```swift
func removingLastComponent() -> FilePath
```

## Discussion

Discussion If the path only contains a root, returns self. If the path has no root and only includes a single component, returns an empty FilePath. Examples: Unix: /usr/bin/ls => /usr/bin /foo        => / /           => / foo         => "" Windows: C:\foo\bar.exe                 => C:\foo C:\                            => C:\ \\server\share\folder\file.txt => \\server\share\folder \\server\share\                => \\server\share\
