<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManager/fileSystemRepresentation(withPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)fileSystemRepresentationWithPath:"
  },
  "title" : "fileSystemRepresentation(withPath:)"
}
-->

# fileSystemRepresentation(withPath:)

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

```
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

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

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)