UBlueprintPathsLibrary::SetExtension
#include "Kismet/BlueprintPathsLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Sets the extension of the given filename, like ChangeExtension, but also applies the extension if the file doesn't already have one.
Caveats & Gotchas
- • Prefer this over ChangeExtension when you need to guarantee the result always has an extension, e.g. before constructing a save path.
- • Passing an empty InNewExtension strips any existing extension rather than leaving it untouched.
Signature
static FString SetExtension(const FString& InPath, const FString& InNewExtension) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InPath | const FString& | The path or filename to set the extension on. | — |
| InNewExtension | const FString& | The extension to apply, with or without a leading dot. | — |
Return Type
FString Example
Ensure a filename has an extension C++
FString WithExt = UBlueprintPathsLibrary::SetExtension(TEXT("Content/Config/Settings"), TEXT("ini"));
// WithExt == TEXT("Content/Config/Settings.ini") Tags
Version History
Introduced in: 4.20
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?