帮助中心帮助中心
将文件夹和子文件添加到工程中
addFolderIncludingChildFiles(proj,folder)
newfile = addFolderIncludingChildFiles(proj,folder)
示例
addFolderIncludingChildFiles(proj,folder) 将文件夹及其所有子文件夹和文件添加到指定的工程中。要仅添加指定的文件夹,而不添加其任何子文件夹和文件,请改用 addFile。
proj
folder
addFile
newfile = addFolderIncludingChildFiles(proj,folder) 为添加的文件返回 ProjectFile 对象。
ProjectFile
全部折叠
打开 Times Table App 工程。使用 currentProject 从当前加载的工程创建一个工程对象。
currentProject
openExample("matlab/TimesTableProjectExample") proj = currentProject;
在工程文件夹中创建一个新的父文件夹。
newFolderPath = fullfile(proj.RootFolder, "newFolder"); mkdir(newFolderPath);
在该父文件夹中创建一个新的子文件夹。
newSubFolderPath = fullfile(newFolderPath, "newSubFolder"); mkdir(newSubFolderPath);
在该子文件夹中创建一个新的文件。
filepath = fullfile(newSubFolderPath, "newVariables.mat"); save(filepath)
将该父文件夹及其子文件夹和文件添加到工程中。检查以确保子文件夹中的文件已正确添加。
projectFile = addFolderIncludingChildFiles(proj, newFolderPath); findFile(proj,"newFolder/newSubFolder/newVariables.mat")
ans = ProjectFile with properties: Path: "C:\myProjects\examples\TimesTableApp\newFolder\newSubFolder\newVariables.mat" Labels: [1×1 matlab.project.Label] Revision: "" SourceControlStatus: Added
matlab.project.Project
工程,指定为 matlab.project.Project 对象。使用 currentProject 从当前加载的工程创建一个工程对象。
要添加到工程中的文件夹的路径,指定为字符向量或字符串标量。指定相对于工程根文件夹的路径。指定的文件夹必须在工程根文件夹中。
在 R2019a 中推出
currentProject | openProject | removeFile | addFile
openProject
removeFile
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office