Main Content

findFile

Find project file by name

Description

example

file= findFile(proj,fileOrFolder)gets the file in the specified project with the specified name. You need to get a file before you can query labels, or use theaddLabelorremoveLabelfunction.

Examples

collapse all

Open the Times Table App project. UsecurrentProjectto create a project object from the currently loaded project.

matlab.project.example.timesTable proj = currentProject;

UsefindFileto get a file by name. If the file is in a subfolder of the project root, you need to specify the full path.

myfile = findFile(proj,"source/timesTableGame.m")
myfile = ProjectFile with properties: Path: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m" Labels: [1×1 matlab.project.Label] Revision: "734fbb2f815848e22694d9ac7ea28953d5e42635" SourceControlStatus: Unmodified

Alternatively, you can get files by index. Get the first file.

file = proj.Files(1);

Find out what you can do with the file.

methods(file)
Methods for class matlab.project.ProjectFile: addLabel findLabel removeLabel

Input Arguments

collapse all

Project, specified as amatlab.project.Projectobject. UsecurrentProjectto create a project object from the currently loaded project.

Path of the file or folder to find, relative to the project root folder, specified as a character vector or string scalar. The specified value must include the full path from the project root to the file, including the names of any subfolders along the way. It must also include the file extension. The file or folder must be within the root folder.

Output Arguments

collapse all

Project file, returned as aProjectFileobject that you can query or modify.

Version History

Introduced in R2019a