UBlueprintPathsLibrary::MakeValidFileName
#include "Kismet/BlueprintPathsLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Strips or replaces every character in InString that GetInvalidFileSystemChars() flags as invalid, producing a string safe to use as a filename.
Caveats & Gotchas
- • Leaving InReplacementChar empty removes invalid characters entirely rather than substituting them, which can cause two different inputs to collapse to the same filename.
- • This does not truncate to the platform's maximum path/filename length, and does not check for reserved names (e.g. "CON" or "NUL" on Windows).
- • It sanitizes filesystem-invalid characters only — it does not validate that the result is a legal Unreal asset name.
Signature
static ENGINE_API FString MakeValidFileName(const FString& InString, const FString& InReplacementChar = TEXT("")); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InString | const FString& | String to sanitize for use as a filename. | — |
| InReplacementChar | const FString& | Character to substitute for each invalid character. If empty, invalid characters are simply removed. | TEXT("") |
Return Type
FString Example
Sanitize a user-entered save name C++
FString UserInput = TEXT("My Save: Chapter 2?");
FString SafeName = UBlueprintPathsLibrary::MakeValidFileName(UserInput, TEXT("_"));
// SafeName == "My Save_ Chapter 2_" Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?