Main Content

addFile

Add file or folder to project

Description

example

addFile(proj,fileOrFolder) 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.

example

newfile = addFile(proj,fileOrFolder) returns a ProjectFile object for the added file.

Examples

collapse all

Open the Times Table App project. Use currentProject to create a project object from the currently loaded project.

matlab.project.example.timesTable
proj = currentProject;

Remove a file.

removeFile(proj,"source/timestable.mlapp")

Add the file back to the project.

addFile(proj,"source/timestable.mlapp");

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.

matlab.project.example.timesTable
proj = currentProject;

Save the current workspace variables to a file.

save("myvariables.mat");

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

collapse all

Project, specified as a matlab.project.Project object. Use currentProject to create a project object from the currently loaded project.

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