---
title: "fileSystemRepresentation(withPath:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanager/filesystemrepresentation(withpath:)"
---

# fileSystemRepresentation(withPath:)

Returns a C-string representation of a given path that properly encodes Unicode strings for use by the file system.

## Declaration

```swift
func fileSystemRepresentation(withPath path: String) -> UnsafePointer<CChar>
```

## Parameters

- `path`: A string object containing a path to a file. This parameter must not be nil or contain the empty string.

## Return Value

Return Value A C-string representation of path that properly encodes Unicode strings for use by the file system.

## Discussion

Discussion Use this method if your code calls system routines that expect C-string path arguments. If you use the C string beyond the scope of the current autorelease pool, you must copy it. This method raises an exception if path is nil or contains the empty string. This method also throws an exception if the conversion of the string fails.

## See Also

### Converting file paths to strings

- [string(withFileSystemRepresentation:length:)](foundation/filemanager/string(withfilesystemrepresentation:length:).md)
