Main Content

mlreportgen.utils.findFile

Find file path

Description

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.

example

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

example

Examples

collapse all

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

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 pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

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.

Version History

Introduced in R2018b