mlreportgen.utils.findFile class

Package: mlreportgen.utils
Superclasses:

Find file path

Construction

filepath = findFile(filename) returns the full file path from the specified file name. The file name can be a partial file name, which is a file name without an extension, or a file name with an extension.

filepath = findfile(filename,Name,Value) returns the full file path with additional options specified by one or more Name,Value pair arguments. Name can also be a property name and Value is the corresponding value. Name must appear inside single quotes ('') or double quotes (" "). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Input Arguments

expand all

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

Name-Value Pair 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.

You can also use strings, specified with double quotes, for name-value pair arguments.

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

List of file extensions, specified as a string, string array, or cell array of strings or character arrays. The function searches for a file name with one of the specified extensions or no extension. If it finds a file name without any of the specified extensions, it returns the file name. To search for more than one file extension, use an array, string array, or cell array.

Example: mlreportgen.utils.findFile(myFile,["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

expand all

Path to file, returned as a string. If the file is in the current working folder, the file name is returned. Otherwise, the full path is returned.

Examples

collapse all

filepath = mlreportgen.utils.findFile('MyFile')
filepath = 
  "C:\Users\username\Documents\MyFile"

In this case, a file named HTMLFile.html exists on the current path.

filepath = mlreportgen.utils.findFile('HTMLFile',["docx" "rtf" "html"])
filepath = 
  "C:\Users\username\Documents\HTMLFile.html"

Introduced in R2018b