Filename Manual


Filename is a special class to handle filenames and paths. It is used to easily construct and edit paths, filenames and suffixes. It also allows to open dialogs to select files and directories.


Filename objects can be created on demand or can be obtained from other entities.

Access Filename objects stored in a BaseContainer:

See also BaseContainer Manual.

Access Filename objects stored in a GeData object (GeData type is DA_FILENAME):

See also GeData Manual.

Important paths are obtained with:

// This example reads the filename parameter of an alembic generator.
BaseObject* object = doc->GetActiveObject();
// check if the active object is an "Alembic Generator"
if (object && object->GetType() == Oalembicgenerator)
GeData data;
// read the "Path to Alembic file" parameter
GePrint("Alembic File: " + data.GetFilename().GetString());


A Filename can be constructed with basic operators:

Only the last part (typically the file) of the given Filename is added.
// This example lets the user select a folder.
// A full file path is constructed and the example checks if that file exists.
Filename selectFolder;
// open a folder selector dialog
if (selectFolder.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, "Select Folder"))
const Filename fullFilePath = selectFolder + "cube.c4d";
// check if given file exists
if (GeFExist(fullFilePath))
GePrint("The folder contains \"cube.c4d\"");
GePrint("The folder does not container \"cube.c4d\"");
// This example constructs the Filename for an image file
// in the plugin's "res" folder and loads this image.
// construct full file name
const Filename imageFile = GeGetPluginPath() + Filename("res") + Filename("arbitrary_icon.tif");
// check if the file exists
if (GeFExist(imageFile))
// load image file into the given BaseBitmap
if (bitmap && bitmap->Init(imageFile) == IMAGERESULT_OK)
// show BaseBitmap in the Picture Viewer


A Filename object can easily be copied:



The content of a Filename object can be represented by a String:

See also String Manual.

// This example prints the full path to the console.
const String filenameString = selectedFile.GetString();
GePrint("File selected: " + filenameString);

File and Directory

A filename may be composed of a directory part and a file part. Each part can be edited independently:

// This example prints the file and the directory to the console.
const String file = selectedFile.GetFileString();
const String directory = selectedFile.GetDirectory().GetString();
GePrint(directory + " - " + file);


Part of the filename may also be the file suffix. This suffix can be edited separately:

// This example checks the suffix of the given filename.
// check if the given Filename references a Cinema 4D scene file
if (selectedFile.CheckSuffix("c4d"))
GePrint("C4D File");
GePrint("Some other file");

It is possible to get the suffix for a given image file type:

// This example adds the correct suffix to the given Filename object
// based on the image file type.
imageFileName = GeFilterSetSuffix(imageFileName, FILTER_JPG);
bitmap->Save(imageFileName, FILTER_JPG, nullptr, SAVEBIT_0);

Memory Mode

The memory mode allows to perform read and write operations on a memory block instead of a file on the hard drive. This is typically used to encrypt or compress the resulting data.

// This example writes some data into memory and accesses the raw memory afterwards.
if (!mfs)
return false;
void* data = nullptr;
Int size = 0;
// open HyperFile to write
if (hyperFile->Open(0, fn, FILEOPEN_WRITE, FILEDIALOG_NONE))
// get raw data
mfs->GetData(data, size, false);
The data stored in memory may be written to a file using HyperFile::WriteMemory().


Select Files and Folders

A Filename object is also useful to open dialogs to select files and folders:

The files that can be selected in a dialog can be filtered with these flags:

The type of dialog is defined with this flag:

// This example shows how to select a file for loading, saving and a folder.
Filename loadFile;
// open a file selector dialog to open a file
GePrint("File to load: " + loadFile.GetString());
Filename saveFile;
// open a file selector dialog to save a file
GePrint("File to save: " + loadFile.GetString());
Filename folder;
// open a folder selector dialog
GePrint("Folder: " + folder.GetString());

Preset Browser

A Filename object may also be used to reference a file located in Cinema 4D's content browser.

// This example checks if the file referenced in a filename parameter is a preset file or not.
GeData geData;
// access a filename parameter
if (node->GetParameter(DescID(ID_FILENAME), geData, DESCFLAGS_GET_0))
const Filename filename = geData.GetFilename();
// check if the given Filename
// is a preset URL
if (filename.IsBrowserUrl())
GePrint("File is stored in presets");


Two Filename objects can be compared easily:

// This example checks if the selected folder is the desktop.
Filename folder;
// open folder selector dialog
if (folder == desktop)
GePrint("You selected the desktop.");
GePrint("You selected " + folder.GetString());

Disc I/O

A Filename object can be stored in a BaseFile or a HyperFile.

// This example writes the Filename into a new BaseFile.
if (!bf)
return false;
// open BaseFile to write
if (bf->Open(filename, FILEOPEN_WRITE, FILEDIALOG_ANY))
// This example reads a String form the given BaseFile.
if (!bf)
return false;
// open BaseFile to read
if (bf->Open(filename, FILEOPEN_READ, FILEDIALOG_ANY))
Filename filenameData;
GePrint("Filename from BaseFile: " + filenameData.GetString());
// This example writes the Filename into a new HyperFile.
if (!hf)
return false;
// open HyperFile to write
if (hf->Open(753, filename, FILEOPEN_WRITE, FILEDIALOG_ANY))
// This example reads a String from the given HyperFile.
if (!hf)
return false;
// open HyperFile to read
if (hf->Open(753, filename, FILEOPEN_READ, FILEDIALOG_ANY))
Filename filenameData;
GePrint("Filename from HyperFile: " + filenameData.GetString());

Further Reading