Main Content


Find file path



filepath = mlreportgen.utils.findFile(filename) returns the full file path from the specified file name. You can specify the file name with or without an extension.


filepath = mlreportgen.utils.findFile(filename,Name,Value) uses additional options specified by one or more Name,Value pair arguments.


collapse all

filepath = mlreportgen.utils.findFile('MyFile')
filepath = 
filepath = mlreportgen.utils.findFile('HTMLFile', 'FileExtensions', ["docx" "rtf" "html"])
filepath = 

Input Arguments

collapse all

File name with or without a file extension, specified as a character vector or string scalar.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: mlreportgen.utils.findFile('myFile','FileExtensions',["htm" "html"])

List of file extensions, specified as the comma-separated pair consisting of 'FileExtensions' and a character vector, string array, or cell array of character vectors. mlreportgen.utils.findFile searches for a file name with one of the specified extensions or no extension.

Example: mlreportgen.utils.findFile('myFile','FileExtensions',["docx" "rtf"])

Specify whether the file to find must exist, specified as true or false. If true, the file must exist. If false, the file does not exist. In this case, only the full path of the file with the specified partial file name is created. No file with that path is created.

Output Arguments

collapse all

Path to file, returned as a string scalar.

Introduced in R2018b