Main Content

addFile

Add files or folders to project

Description

addFile(proj,filesAndFolders) adds files and folders 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

newfiles = addFile(proj,filesAndFolders) returns an array of ProjectFile objects for the added files.

example

Examples

collapse all

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");

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.

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 files and folders to add to the project, specified as a string array or a cell array of character vectors. The specified files or folders must be within the project root. File paths must include the file extension.

Version History

Introduced in R2019a

expand all