Skip to content

FileManager.createNewFile method

FileManager › createNewFile

Unofficial

Create a new file in the vault at specified location.

Signature:

createNewFile(location?: TFolder | undefined, filename?: string | undefined, extension?: string | undefined, contents?: string | undefined): Promise<TFile>

Parameters:

Parameter Type Description
location? TFolder | undefined Location to create the file in, defaults to root.
filename? string | undefined Name of the file to create, defaults to 'Untitled' (incremented if file already exists).
extension? string | undefined Extension of the file to create, defaults to 'md'.
contents? string | undefined Contents of the file to create, defaults to empty string.

Returns: Promise<TFile>A promise that resolves to the newly created file.