addFile - Add file or folder to project - MATLAB (original) (raw)
Main Content
Add file or folder to project
Syntax
Description
addFile([proj](#mw%5F6e6ce1a5-689a-413d-a43f-c5f145d7409d),[fileOrFolder](#mw%5F97dae1a4-cc95-448d-a72f-3edfe0c07f29))
adds a file or folder to the project proj
. When adding a folder to the project, MATLAB® only adds the specified folder. To add the folder including any all subfolders and files, use addFolderIncludingChildFiles instead.
newfile = addFile([proj](#mw%5F6e6ce1a5-689a-413d-a43f-c5f145d7409d),[fileOrFolder](#mw%5F97dae1a4-cc95-448d-a72f-3edfe0c07f29))
returns a ProjectFile
object for the added file.
Examples
Remove and Add Project Files
Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
openExample("matlab/TimesTableProjectExample") proj = currentProject;
Remove a file.
removeFile(proj,"source/timestable.mlapp")
Add the file back to the project.
addFile(proj,"source/timestable.mlapp");
Manipulate Project Files After Adding
Add a file to the project and then manipulate the file using the returned project file object.
Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
openExample("matlab/TimesTableProjectExample") proj = currentProject;
Save the current workspace variables to a file.
Add the new file to the project and return a project file object.
file = addFile(proj,"myvariables.mat");
Use the project file object to manipulate the file, for example, by adding a label.
addLabel(file, "Classification", "Other")
Input Arguments
proj
— Project
matlab.project.Project
object
Project, specified as a matlab.project.Project
object. Use currentProject to create a project object from the currently loaded project.
fileOrFolder
— Path of file or folder
character vector | string scalar
Path of the file or folder to add to the project, specified as a character vector or string scalar. Specify a path relative to the project root folder. The specified file or folder must be within the project root folder. File paths must include the file extension.
Version History
Introduced in R2019a