Find project file by name
Open the Times Table App project. Use
to create a project object from the currently loaded project.
matlab.project.example.timesTable proj = currentProject;
findFile to 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: "" 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 for class matlab.project.ProjectFile: addLabel findLabel removeLabel
Project, specified as a
currentProject to create a project object from the currently
fileOrFolder— Path of file or folder
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.
file— Project file
Project file, returned as a
ProjectFile object that you
can query or modify.