findFile
按名称查找工程文件
说明
从指定工程中获取具有指定名称的文件。您需要先获取文件才能查询标签,或者使用 file
= findFile(proj
,fileOrFolder
)addLabel
或 removeLabel
函数。
示例
按名称查找文件
打开 Times Table App 工程。使用 currentProject
从当前加载的工程创建一个工程对象。
openExample("matlab/TimesTableProjectExample")
proj = currentProject;
使用 findFile
按名称获取文件。如果文件位于工程根目录的子文件夹中,则需要指定完整路径。
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: "734fbb2f815848e22694d9ac7ea28953d5e42635" SourceControlStatus: Unmodified
您也可以通过索引获取文件。获取第一个文件。
file = proj.Files(1);
了解您可以使用该文件做什么。
methods(file)
Methods for class matlab.project.ProjectFile: addLabel findLabel removeLabel
输入参数
proj
— 工程
matlab.project.Project
对象
工程,指定为 matlab.project.Project
对象。使用 currentProject
从当前加载的工程创建一个工程对象。
fileOrFolder
— 文件或文件夹的路径
字符向量 | 字符串标量
要查找的文件或文件夹的路径(相对于工程根文件夹),指定为字符向量或字符串标量。指定的值必须为从工程根目录到文件的完整路径,包括任何子文件夹的名称。它还必须包括文件扩展名。文件或文件夹必须在根文件夹中。
输出参数
file
— 工程文件
ProjectFile
对象
工程文件,返回可查询或修改的 ProjectFile
对象。
版本历史记录
在 R2019a 中推出
MATLAB 命令
您点击的链接对应于以下 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:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)